Photo courtesy of Flickr user cindy

Alright, so @philnash roped me into this one. This keeps in line with my other posts that are “Not just a Gist”. If you want to read about those posts, check out these:

This post’s birth comes from a gist which is essentially a copy paste of my git aliases.

I’m going to provide my list of git aliases and explain what each alias does, plain and simple. Let’s get started! 🏁 For those new to git aliases, please see the defacto docs on aliases.

Before we get started, why git aliases? Well for one thing, I don’t know about you, but some git commands are hard to remember and also, we’re programmers, which means we’re lazy by default to be efficient. 🐢 —> 🐇

  1. alias.a add .
  2. Running git add will add all files that have changed as staged.
  3. alias.aliases config --get-regexp alias
  4. Running git aliases will show all the aliases you have configured globally in git.
  5. alias.bi bisect
  6. Running git bi will run git’s bisect to help you figure out which commit has a bug.
  7. alias.ci commit -m
  8. This will commit a file with the message you specify, e.g. git ci "awesome commit!" .
  9. alias.co checkout
  10. This will checkout the branch you specify, e.g. git co my-awesome-branch
  11. alias.colast checkout -
  12. Running git colast will checkout the previous branch you were working in.
  13. alias.db branch -D
  14. This will delete the branch you specify, e.g. git db my-not-so-awesome-branch . Note that this will only work if the branch you’re deleting is not the one you’re currently working in.
  15. alias.laf fsck --lost-found
  16. Running git laf will bring you to git’s lost and found. I’ll admit that I rarely use this, so perhaps it doesn’t warrant an alias and just some professional Googling.
  17. alias.last log -1 HEAD
  18. Running git last will show you what your last commit was.
  19. alias.nb checkout -b
  20. This will create a new branch, e.g. git nb my-awesome-branch .
  21. alias.pror remote prune origin
  22. Running git pror will do some cleanup on the origin remote via pruning.
  23. alias.pr pull --rebase
  24. This will rebase your current branch with the branch specified, e.g. git pr develop .
  25. alias.ra rebase --abort
  26. Running git ra will abort a rebase. Run this when you’re like, my rebase is currently messed up. Get me outta here!
  27. alias.rc rebase --continue
  28. Running git rc will continue a rebase. You typically run this when you’ve handled any conflicts in a rebase.
  29. alias.pf push --force-with-lease
  30. Running git pf forces a push, but it is a little less destructive than forcing a push. See here for more info on —force-with-lease vs. —force.
  31. alias.psu push --set-upstream
  32. Run this when you want to push a branch for the first time to the remote (typically origin ), e.g. git psu origin my-awesome-branch .
  33. alias.remotes remote -v
  34. Running git remotes shows all the remotes currently configured for a repository.
  35. alias.renb branch -m
  36. When you want to rename a branch, run e.g. git renb my-awesom-branch my-awesome-branch .
  37. alias.rhh reset --hard HEAD
  38. The nuclear option. Run git rhh to wipe out all your changes and start from the HEAD .
  39. alias.rh reset --hard
  40. When you specify what to reset to, a hard reset is performed, e.g. git rh HEAD~2 .
  41. alias.s status -s
  42. Running git s will give you a more terse status. Instead of this
On branch post/my-git-aliases
Your branch is up to date with 'origin/post/my-git-aliases'.

Changes not staged for commit:
 (use "git add <file>..." to update what will be committed)
 (use "git checkout -- <file>..." to discard changes in working directory)

       modified: src/pages/articles/2018-08-24-my-git-aliases/index.md

no changes added to commit (use "git add" and/or "git commit -a")

You get this

M src/pages/articles/2018-08-24-my-git-aliases/index.md
  1. alias.stashes stash list
  2. Running git stashes shows you all the stashes you have from stashing. e.g.
stash@{0}: WIP on upgrade: bff6257 Destructuring OCD...
stash@{1}: WIP on upgrade: 3d73199 Fixed LiceCap link.
stash@{2}: WIP on upgrade: c2f78g6 Update default title.
  1. alias.unstash stash pop
  2. Running git unstash pops a stash off the list of saved stashes.
  3. alias.vc clean -dfx
  4. Running git vc cleans your git repository, so anything not in git is wiped, e.g. node_modules , settings files which aren’t supposed to be in a repo etc. So BEWARE before you run this.
  5. alias.refactor commit -m 👷Refactor
  6. When running git refactor , a generic refactor message is used for committing any staged files, i.e. 👷Refactor . I’ll probably improve on this to just allow a user to concatenate a custom message to it. But that’s for another day.
  7. alias.formatting commit -m 💅Formatting
  8. When running git formatting , a generic formatting message is used for committing any staged files, i.e. 💅Formatting . I’ll probably improve on this to allow a user to concatenate a custom message to it. But that’s for another day.
  9. alias.comments commit -m 📒Comments
  10. When running git comments , a generic comments message is used for committing any staged files, i.e. 📒Comments . I’ll probably improve on this to allow a user to concatenate a custom message to it. But that’s for another day.
  11. alias.tests commit -m ✅Tests
  12. When running git tests , a generic tests message is used for committing any staged files, i.e. ✅Tests . I’ll probably improve on this to allow a user to concatenate a custom message to it. But that’s for another day.
  13. alias.prum pull --rebase upstream master
  14. Running git prum rebases your current branch off your upstream remote.
  15. alias.mend commit --amend
  16. Running git mend lets you amend a commit.

FIN