Skip to content

Instantly share code, notes, and snippets.

@brennanMKE
Last active February 26, 2025 18:10
Show Gist options
  • Save brennanMKE/ba7ad70c1238bfd726dc63cb6bcf8b03 to your computer and use it in GitHub Desktop.
Save brennanMKE/ba7ad70c1238bfd726dc63cb6bcf8b03 to your computer and use it in GitHub Desktop.
Essential Git Aliases

Essential Git Aliases

The following Git aliases are very helpful for my usual workflow.

[alias]
	cb = switch -c
	sw = switch
	wip = commit -m wip
	rr = pull --rebase origin
	fixup = !git reset --soft HEAD~1 && git commit --amend --no-edit
	publish = !git push --set-upstream origin $(git rev-parse --abbrev-ref HEAD)
	nudge = push --force-with-lease
	shove = push -f
	lrb = !sh -c '\nten_days_ago=$(date -v-10d +%Y-%m-%d) &&\ngit for-each-ref --sort=committerdate --format \"%(committerdate:short) %(refname:short)\" refs/heads/ |\nawk -v date=\"$ten_days_ago\" \"\\$1 >= date { print }\"\n'

Create a branch

git cb new-branch

Switch branch

git sw other-branch

Work in Progress

Commits current changes with "wip" as the commit message. It is helpful to create several commits as checkpoints during development on a feature branch.

git wip

Rebase Remote

Pulls from origin and rebases current branch. This is helful to stay current on a feature branch during development.

git rr main

Fix up

Combines latest commit with the previous commit and uses the commit message of the previous commit. This is great for combining a WIP commits before pushing to a remote branch.

git fixup

Push changes to new remote

git publish

Force push (safe)

git nudge

Force push (unsafe)

git shove

List recent branches

List the 10 most recent and shows date. This is useful for changing between the main branch and feature branches.

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