Git Quickstart: Notes from Taming the Beast
Git
DevTools
Archive
Practical Git notes covering tree visualization in the terminal, merge conflict resolution with vimdiff, and safe fetch vs pull workflow.
Git is a fantastic developer tool but it’s a messy tool. Below is a collection of my notes and references, which I collected while trying to tame this beast.
Git 101
See git tree in terminal
Once you get the basics, you would want to see the tree and branches of your repo. This is especially handy when you are working with remote servers like AWS, rackspace et al.
Quick command to see tree in terminal:
git config --global alias.tree 'log --graph --full-history --all --color --date=short --pretty=format:"%Cred%x09%h %Creset%ad%Cblue%d %Creset %s %C(bold)(%an)%Creset"'Merge Conflicts
- Definitive reference for fixing merge conflicts: Link
- To check the status of local vs remote files:
git remote show - Can use
git fetchtoo. Never usegit pull, it will fetch and merge whatever it wants to. - To check what changes will be made if you fetch the remote:
git diff HEAD / - Use the following command to check the available diff/merge tools:
git mergetool --tool= - To use vimdiff install vim:
sudo apt-get install vimand then run:
git config --global diff.tool vimdiff
git config --global difftool.vimdiff.cmd "vimdiff $LOCAL $REMOTE"Now run git difftool to diff.
Some Tricks
- Show branch name in the bash: Link