bgve_w
Last Updated: February 25, 2016
·
1.544K
· passcod

Show last commit on `git status`

git

When I run git status, I like to have the last commit message and SHA as well: it reminds me of what I just did and what I'm about to commit. Also, I like to alias git status to git ls (it does list stuff, after all).

Here's how it looks:

12:12pm passcod:~/pippo$ git ls
# HEAD: 31409c0 Simplify #set_documents; remove docid duplication
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       new file:   bin/.gitkeep
#
# 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)
#   (commit or discard the untracked or modified content in submodules)
#
#       modified:   docs (modified content)
#       modified:   server.rb
#       modified:   store.rb
#       modified:   transaction.rb
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       Makefile
#       a.out
#       bin/pippo-store
#       store.c
#       test/

And here's how it works:

[alias]
  ls = "!cd ${GIT_PREFIX:-`pwd`}; printf \"# HEAD: \"; git log --oneline | head -n1; git status"

It will error out and print some garbage if you use it in a bare repo (duh!), a just-init'd repo (less obvious), or in detached branch mode (can be surprising). But otherwise it's great!