Skip to content

Instantly share code, notes, and snippets.

@antonkomarev
Last active September 4, 2025 16:37
Show Gist options
  • Save antonkomarev/7195a4b0cd63cf4e2515256050c7e895 to your computer and use it in GitHub Desktop.
Save antonkomarev/7195a4b0cd63cf4e2515256050c7e895 to your computer and use it in GitHub Desktop.
Useful git aliases to speed up development
[alias]
go = "!git switch ${1:-master} && git pull && git cleanup"
rh = "!git rebase -i HEAD~$(git count)"
ru = "!git rebase -i master"
pf = "!git push --force-with-lease"
# secondary tool functions
cleanup = "!git fetch -p && git branch -vv | awk '/: gone]/{print $1}' | xargs git branch -D"
count = "!git rev-list --count HEAD ^$(git merge-base HEAD master)"

git go

  1. Switches to a selected branch (master by default)
  2. Pulls changes from the 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 rh

Opens an interactive rebase for all commits in the current branch that are not yet in master, automatically calculating the number of commits to rebase.
Useful for squashing or editing only your new commits.

git sq

git ru

Opens an interactive rebase of the current branch on top of master, using master as the fixed base.
All commits in the branch will be reordered relative to master.

git ru

git pf

Force push with --force-with-lease flag.

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