Skip to content

Instantly share code, notes, and snippets.

@BrianValente
Last active April 4, 2025 18:36
Show Gist options
  • Save BrianValente/2ced29c93f2fbd53148bfd9e880535ff to your computer and use it in GitHub Desktop.
Save BrianValente/2ced29c93f2fbd53148bfd9e880535ff to your computer and use it in GitHub Desktop.
Git aliases
# Git: Force push current branch
alias gpf="git push --no-verify --force-with-lease --force-if-includes"
# Git: Get the commit hash from which the current branch was forked
alias gfch="diff -u <(git rev-list --first-parent \$(git rev-parse --abbrev-ref HEAD)) <(git rev-list --first-parent origin main) | sed -ne 's/^ //p' | head -1"
# Git: Rebase interactive commits compared to the branch from which the current branch was forked
alias gri="git rebase -i \$(gfch)"
# Git: Rebase interactive commits compared to the branch from which the current branch was forked with autostash
alias gria="gri --autostash"
# Git: Pull origin main with rebase and autostash
alias gprom="git pull --rebase origin main --autostash"
# Git: Amend last commit without editing the commit message
alias gcan="git commit --verbose --all --no-edit --amend"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment