Dave's Blog

Git for beginners


July 12, 2017

I've added some info to our internal Confluence wiki for new devs who don't have a git background. That group included me a year ago so I recall how much of a mind shift it is from a centralised VCS.

Here are my notes/links for future ref (as much by me as anyone else).

SSH:

Once you have set up your account on BitBucket, follow the steps on Bitbucket (dropping down "Set up SSH for Windows") to step up SSH. I would stop at step 6 as at that point you can clone the repos.

Configure git

Mandatory. In git bash:

git config --global user.email \[your email\]
git config --global user.name \[your name\]

Optional:

  • Set your favourite mergetool for merging: git config --global merge.tool "winmerge". You can see a list of which suitable tools you currently have installed by running: git mergetool --tool-help
  • Create an alias for a customised version of git log (usage : git lg): git config --global alias.lg "log --pretty=' %Cred%h%Creset | %C(yellow)%d%Creset %s %Cgreen(%cr)%Creset %Ccyan%Creset' --graph"
  • Improves git diff tool: git config --global diff.algorithm histogram
  • Make merge issues show the base file before conflicts as well as the actual conflicts: git config --global merge.conflictStyle diff3
  • Configure Git-Bash (if you intend on using it) to point to your local repository file path by default each time it loads up
  • Right click on the Git Bash.exe shortcut and click Properties.
  • In the Shortcut Tab, enter your local Git repository path in the "Start In" textbox. For example, C:\\Git
  • If present, remove the --cd-to-home text from the Target path as this effectively overrides the 'Start In' path

Learning git

There are two tools to help you get to grips with branching (with live testbeds):