- How to abort
git commit
- if inside vim, just do
:cq!
- if inside vim, just do
- Rename a local and remote branch
- git branch -m new-name
- git push origin :old-name new-name
- git push origin -u new-name
- Delete a remote branch
- git push origin --delete branch-name
- Delete remote-tracking branches no longer exist on the remote
- git fetch origin --prune
- Search git commit messages
- git log --oneline | grep PATTERN
- Start ignoring changes to a file
- git update-index --assume-unchanged path/to/file
- Keep tracking files again
- git update-index --no-assume-unchanged path/to/file
- Find commit that introduced a string
- git log --all -p --reverse --source -S PATTERN
- How to exclude files only on your computer
- add patterns in
.git/info/exclude
- same way in .gitignore
- add patterns in
- Delete untracked files
- git clean -f
- Reverting part of a commit
- git revert -n $bad_commit # Revert the commit, but don't commit the changes
- git reset HEAD . # Unstage the changes
- git add --patch . # Add whatever changes you want
- git commit # Commit those changes
- List active remote branches
- git fetch -p && git for-each-ref --format='%(align:25,left)%(color:yellow)%(authorname)%(end) %(color:reset)%(refname:strip=3)' --sort=authorname refs/remotes
?
— untracked changes;+
— uncommitted changes in the index;!
— unstaged changes;»
— renamed files;✘
— deleted files;$
— stashed changes;=
— unmerged changes;⇡
— ahead of remote branch;⇣
— behind of remote branch;⇕
— diverged changes.
- hotfix - hotfix/ master
- feature - feature/ develop
- bugfix - bugfix/ develop
- release - release/ develop
- feat - A new feature;
- fix - A bug fix
- docs - Documentation only changes
- style - Changes that do not affect the meaning of the code
- refactor - Neither fixes a bug nor adds a feature
- perf - Improves performance
- test - Adding missing tests or correcting existing tests
- build - Changes that affect the build system or external dependencies
- ci - Changes to our CI configuration files and scripts
- chore - Other changes that don't modify src or test files
- revert - Reverts a previous commit