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.
Author

B. Talvinder

Published

November 14, 2015

From the Archive

Originally published in 2015 on talvinder.com. Some technical details may be outdated, but this remains here as part of the archive.

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

  • Pretty awesome article to begin with: Link
  • To the point git tutorial with great configuration commands: Link

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 fetch too. Never use git 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 vim and 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

Enjoyed this?

Get frameworks, build logs, and field notes in your inbox.

No spam. Unsubscribe anytime.