Skip to content

Instantly share code, notes, and snippets.

@antonkomarev
Last active December 12, 2025 05:14
Show Gist options
  • Select an option

  • Save antonkomarev/7195a4b0cd63cf4e2515256050c7e895 to your computer and use it in GitHub Desktop.

Select an option

Save antonkomarev/7195a4b0cd63cf4e2515256050c7e895 to your computer and use it in GitHub Desktop.
Useful git aliases to speed up development
[alias]
cleanup = "!git fetch -p && git branch -vv | awk '/: gone]/{print $1}' | xargs git branch -D"
go = "!git switch ${1:-master} && git pull && git cleanup"
count = "!git rev-list --count HEAD ^$(git merge-base HEAD master)"
sq = "!f() { \
count=$(git rev-list --count HEAD ^$(git merge-base HEAD @{upstream})); \
git rebase -i HEAD~$count; \
}; f"

Add 2 aliases to ~/.gitconfig file.

git cleanup

  1. deletes all local branches which were deleted remotely.
git cleanup

git go

  1. switches to seleted branch (master by default)
  2. pulling changes from remote server
  3. deletes all local branches which were deleted remotely
git go

Same command, but with another branch name to switch to.

git go feature/custom-branch-name

git count

Calculates the number of commits that are not in master branch.

git count

git sq

Opens an interactive rebase for all commits in the current branch that are not in master branch.

git sq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment