Skip to content

Instantly share code, notes, and snippets.

@kedarvaidya
Last active March 9, 2021 18:48
Show Gist options
  • Save kedarvaidya/90bd2fe71aeb7f79eba0b27318a08e84 to your computer and use it in GitHub Desktop.
Save kedarvaidya/90bd2fe71aeb7f79eba0b27318a08e84 to your computer and use it in GitHub Desktop.
List of git aliases that I have configured globally in my system
Alias Command Usage Description
st status git st Show the working tree status
co checkout git co <my-branch> Switch to branch named <my-branch>
cob checkout -b git cob <my-new-branch> Create and switch to new branch named <my-new-branch>
cm !git add -A && git commit -m git cm "<my-message>" Add all changes including untracked files to the index and commit them to the repository with message "<my-message>"
mc merge --no-edit git mc <my-branch> Merge <my-branch> with auto-generated message
ma merge --abort git ma Abort the current conflict resolution process, and try to reconstruct the pre-merge state.
rb rebase git rb <my-branch> Apply the changes introduced by some existing commits
rbc rebase --continue git rbc Restart the rebasing process after having resolved a merge conflict
rba rebase --abort git rba Abort the rebase operation and reset HEAD to the original branch
rbi rebase --interactive git rbi <my-commit-ref> Make a list of the commits which are about to be rebased. Let the user edit that list before rebasing.
cp rebase git cp <my-commit-ref> Reapply commits on top of another base tip
cpc rebase --continue git cpc Continue after resolving conflicts in a failed cherry-pick or revert.
cpa rebase --abort git cpa Abort the cherry-pick operation and return to pre cherry-pick state
undo reset HEAD~1 --mixed git undo Resets the previous commit, but keep all the changes from that commit in the working directory
undo-hard reset HEAD~1 --hard git undo-hard Resets the previous commit and discards all changes in that commit
discard !git cm 'To be discarded' --no-verify && git undo-hard git discard Discards current working tree changes
unstage reset HEAD -- git unstage Unstage all changes in current working tree
amend commit -a --amend git amend Add modifications and deletions for existing files but ignore brand new files and also launches default commit editor allowing user to change commit message
amendne commit -a --amend --no-edit git amendne Add modifications and deletions for existing files but ignore brand new files without changing the commit messages
diffc diff --cached git diffc <my-commit-ref> Show diff of all staged changes relative to <my-commit-ref>
diffns diff --name-status git diffns <my-commit-ref> Show only names and status of all new, modified and deleted files relative to <my-commit-ref>
ml !git branch --merged master | grep -v '^* master$' | grep -v '^ master$' git ml Show list all local branches that have been merged into master
dml !git ml | xargs -n 1 git branch -d git dml Delete all local branches that have been merged into master
git config --global alias.egc 'config --global -e'
git config --global alias.elc 'config --local -e'
git config --global alias.st 'status'
git config --global alias.co 'checkout'
git config --global alias.cob 'checkout -b'
git config --global alias.cm '!git add -A && git commit -m'
git config --global alias.mc 'merge --no-edit'
git config --global alias.ma 'merge --abort'
git config --global alias.rb 'rebase'
git config --global alias.rbc 'rebase --continue'
git config --global alias.rba 'rebase --abort'
git config --global alias.rbi 'rebase --interactive'
git config --global alias.cp 'cherry-pick'
git config --global alias.cpc 'cherry-pick --continue'
git config --global alias.cpa 'cherry-pick --abort'
git config --global alias.undo 'reset HEAD~1 --mixed'
git config --global alias.undo-hard 'reset HEAD~1 --hard'
git config --global alias.discard '!git cm "To be discarded" --no-verify && git undo-hard'
git config --global alias.unstage 'reset HEAD --'
git config --global alias.amend 'commit -a --amend'
git config --global alias.amendne 'commit -a --amend --no-edit'
git config --global alias.diffc 'diff --cached'
git config --global alias.diffns 'diff --name-status'
git config --global alias.ml '!git branch --merged master | grep -v "^* master$" | grep -v "^ master$"'
git config --global alias.dml '!git ml | xargs -n 1 git branch -d'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment