As you may know, Git is not a single application, but rather a toolkit containing many small programs and scripts that can manipulate the repository. This makes it trivial to chain those components into more-powerful, custom commands which can be defined as git aliases.
Here are some of the more-useful aliases I use on a daily basis:
(To install these, simply drop copypaste the lines above into your
This is a simple alias which performs a
git pull --ff-only. I can run
git p in any repository to ensure I always have the latest version of that branch without accidentally creating extra merge commits.
gix fixup <commit>
This one is probably my favorite - it automates the process of amending any previous commit with the currently-staged changes. For example, if I need to amend the commit before the current one, I can simply run something like this:
vi somefile.ext git add somefile.ext git fixup HEAD^
Any commit or "tree-ish" should work for the argument:
This solution is much more elegant than my old
git amend-old script which worked fine but was overly complicated.
This command will delete all local branches which have been merged into the current branch, except those named
develop which it'll never delete. It's an easy way to keep your local repo clean.
Git commits are directly tied to their parents, making it easy to navigate backwards through the history. But what if you've checked out some random commit and want to move forwards instead?
git children will identify all known commits which have the current
HEAD as their parent!
git aliases are you using? Let me know in the comments!