Posted on: Written by: K-Sato
⚠️ This article was posted over 2 years ago. The information might be outdated. ⚠️

Table of Contents

Dealing With Merge Conflicts

git push の取り消し方法

Put commits together

$ git rebase -i HEAD~4

Check out remote branch onto your local pc

$ git checkout -b other_branch origin/other_branch

Git Command Aliases

git config --global alias.co checkout
git config --global alias.ci commit
git config --global alias.st status
git config --global alias.br branch

Untrack already tracked filed

## File
$ git rm --cached <file-name>

## Directory
git rm -r --cached directory/

Git Reset

--soft: uncommit changes, changes are left staged (index).
--hard: uncommit + unstage + delete changes, nothing left.
--mixed (default): uncommit + unstage changes, changes are left in working tree.

Git Tags

# Show all tags
$ git tag
# Create a tag
$ git tag -a v1.4 -m "my version 1.4"
# Create a tag with a specific commit hash
$  git tag -a v1.2 9fceb02 -m 'my version 0.1.0'
# Show the tag data along with the commit that was tagged
$ git show v1.4
# Sharing a tag
$ git push origin v1.5
# Sharing tags
$ git push origin --tags
# Deleting tags
$ git tag -d v1.4
# Delete a remote tag
$ git push origin --delete <tagname>

Git Unstage staged files/directories

The command below unstage all the staged files.

$ git reset HEAD
# Stage files exept a directory (In this case, it's staging all the files and directories besides stuff under the vendor directory.
$ git add . && git reset -- vendor/*

Fix folder name to uppercase/lowercase in git

Remove all untracked directories and files

git clean -n
git clean -df // use -f if you just wanna delete untracked files.

Grep specific branches

& git branch --all | grep <id>

About the author

I am a web-developer based somewhere on earth. I primarily code in TypeScript, Go and Ruby at work. React, RoR and Gin are my go-to Frameworks.