Senthilkumar Gopal

thoughts, code, ramblings and notes

23 January 2014

Git commandline and Github are two of most used tools for a web developer. Especially in a team environment, we use these more than a few times in a day. Recently I came across a screencast held at Aloha Ruby Conference. Some of the important and amazing shortcuts and useful tips discussed were summarized below. Rather than using them all, we should start couple of them and start practising them which definitely improves our tooling and productivity.


Adding .diff or .patch to the URL provides more clearer textual representation

Remove Whitespace differences using ?w=1

Cool octocat images @

URL Shortner :
Usage: gitio <url> <name?

Lexer and Highlighting Languages: Linguist

Gist as Screenshot sharing and discussion tool <>

Git + Hub super commands
Hub is a command line tool that wraps git in order to extend it with extra features and commands that make working with GitHub easier.
hub repo

Key Shortcuts
Press in repo page
t - for File Finder
w - branch selector
s - quick search

@mention - adds person to the conversation
@Organization/Team - adds the organization/team to the conversation

#<number> - autolinks to issue number
Example: using a commit message such as "closes #1291" autolinks to the issue

Adding ?author=sengopal or email address to gives the list of commits by that author.
Useful for your resume !

Pulls needn't be from a fork, but can be done from branches as well

Github supports emoji's which are available under Emoji-cheat-sheet

Git line quirks

  1. git branch --merged

  2. git branch --no-merged

  3. git branch --contains <sha> - which branch has this SHA

  4. git checkout <branch_name> --<path to file> - checkout that file from that branch into your current branch

  5. git log branchA ^branchB - commits in A not in B

  6. git fsck ==lost-found

  7. git diff HEAD^ --stat

  8. git blame -w - to avoid whitespace as commits

  9. git blame -M - original commit and not the move commit

  10. git blame -C - same as M except looks in the same commit
    -CC, -CCC are the other variations available

  11. git status -sb

  12. git diff HEAD^ --word-diff

  13. git config --global help.autocorrect 1

  14. git config --global rerere.enabled 1 - long running branches, remembers merge conflicts

  15. git config --global color.ui 1

  16. git-amend - alias to git commit --amend -C HEAD

  17. git undo - alias to git reset --soft HEAD^ - retains commit as staged

  18. git-count - alias to git shortlog -sn

  19. git add -p - useful for logical commits

  20. git show :/<query> - checks for the message or file name

Commit Comparison
LINE Linking - #L16, #L16-25

Advanced Compare View
Range - MASTER@{}...MASTER
bookmark that page and see whats team upto in last 12 hours

Key Git commands in order of importance