Tricks in git
TL;DR:
- git pickaxe
- git add -p (add just specific changes to staging)
- tig (useful commandline tool)
- use git aliases to save keystrokes in your .basrc file
- Octothree (browser extension)
If you are trying to find how code inside the project changed through time you can used so called git pickaxe.
What this does is shows you all the commits and its content (oldest commits first).
Cool git command I use regularly is
Which enables you to add specific code to staging and not just the whole file.
If you want to see what commit changes were made on particular file
--
says that this is current branch. You can add --patch
before --
to see the changes.
One command line tool I enjoy using is tig. I mostly use it for inspecting commits, commit history, diffs etc.
Because I often use commands like the ones listed below
To save few keystrokes I added these commands to aliases in my .zshrc file. If you use Bash you can add them to your .bashrc file.
The next trick is not just git specific but I found it so useful that I want to mention it here. If you use github and miss navigating the source code in the same way as in your text editor you can install Octothree. This is browser extension that enables you to navigate files and folder in a tree like structure.