Jessitron’s favorite git aliases

so I can find them here later:

Fast-forward merge

Some people like to git pull, but I never do. That brings new stuff from origin and then merges. I always do these do steps separately: git fetch and then either merge or rebase. The easy case, when I don’t have any local-only commits, is to do a fast-forward merge. That moves my local branch pointer forward to match origin’s, and rearranges my files. I do this with git ff for “fast-forward merge; fail if I have any local commits that I should rebase.”

git config --global alias.ff "merge --ff-only"

Absorb changes into the previous commit

Often I want to slide a quick typo fix into the commit I just made. I can add the files to the cache with git add . (or just a part of the changes with git add -p). Then to mush them into the last commit, I do git fix.

git config --global alias.fix "commit --amend --no-edit"

It’s like, I could type git commit --amend except with the two m’s in commit and the two dashes I always type ammend and get an error. And then it opens the editor and I didn’t want to change the message and I never remember the option for –no-edit. The alias makes it easy.

See also: git home https://jessitron.com/2015/05/25/git-handy-alias-to-find-the-repository-root/