My Favorite Git Commands

Git aliases

Redin Gaetan
1 min readSep 26, 2021

I centralize here all my favorite git command to easy use it and be faster.

git undo

How to undo the last commit

git config --global alias.undo 'reset --soft HEAD^'

Usage:

git undo

git upd

How to update from a remote branch

git config  --global alias.upd '!f() { git fetch origin && git rebase origin/$1; }; f'

Usage

git upd master
git upd develop
...

git new

How to create a new branch

git config  --global alias.new "checkout -b"

Usage

git new <my_branch>

git st

How to see the current git status

git config  --global alias.st "status"

Usage

git st

git gone

Allow to remove unused locale branches, which are present on remote.

git config --global alias.gone "!f() { git fetch --all --prune; git branch -vv | awk '/: gone]/{print $1}' | xargs git branch -D; }; f"

Pick here by Andrew Luca.

Usage

git gone

git alias

Allow to list all created aliases.

git config --global alias.alias '!f() { git config --list | grep alias; }; f'

Usage

git alias

--

--