5 Minute Tips: Git

Here’s one for Monday morning. A few Git commands that you might want to add to your toolbox as well:

  • Partial repository download:
  • Review your code during git add with -p, use git diff --cached to see the full diff of the currently staged files with HEAD, i.e. only what you have added, and show the details of the latest commit with git show (-w ignores whitespace changes, just as in git diff).
  • Who hasn’t ever used something like “Initial commit” as commit message? It can make sense to start with an empty commit while you are at it:
  • And I have to add my favorite Git command of all time. If you don’t know the --graph argument yet, try it out and be amazed:
    git log --graph --oneline --decorate --all --color

    You might want to add it as alias like “tree”, but for me it is enough to always find it in the bash history with CtrlR “git log” quickly.

Git is an endless source of new tricks to learn, expect more “5 Minute Tips” on Git to come.

2 Replies to “5 Minute Tips: Git”

  1. Great post! I’ve started using the first command quite a bit.

    The last command is nifty, although I tend to stick with SourceTree for visualizing branches.

    Speaking of “Ctl+R” to search history, if you aren’t already using up/down arrow to search Bash history, then you should be. Check this out: http://stackoverflow.com/a/1030206/2726785

Comments are closed.