⚠️ 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
- Check out remote branch onto your local pc
- Git Command Aliases
- Untrack already tracked filed
- Git Reset
- Git Tags
- Show all tags
- Create a tag
- Create a tag with a specific commit hash
- Show the tag data along with the commit that was tagged
- Sharing a tag
- Sharing tags
- Deleting tags
- Delete a remote tag
- Git Unstage staged files/directories
- Stage files exept a directory (In this case, it's staging all the files and directories besides stuff under the vendor directory.
- Fix folder name to uppercase/lowercase in git
- Remove all untracked directories and files
- Grep specific branches
Dealing With Merge Conflicts
git push の取り消し方法
Put commits together
- Squash All Commits Related to a Single Issue into a Single Commit · todotxt/todo.txt-android Wiki · GitHub
- rebase -i でコミットをまとめる - Qiita
- 他人のコミットを git merge —squash するべきでないのではという話 - Qiita
$ 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>