Sunday, July 7, 2013

git install --windows


There are two competing Git packages for Windows: a Cygwin-based Git and msysGit. I will describe how to install the msysGit package

Run the installer (Git-1.8.4-preview20130916.exe  at the time of writing) :
  • explorer integration : simple context menu (I haven't tried the cheetah one)
  • Use git Bash only (at least for starters) - see here for a hack
  • Configure line endings : that's a complicated one. Bottom line : choose Checkout as-is, Commit as-is and be sure to setup a .gitattributes file in all of your repos. I will blog about this soon.
First of all, on installing, if not on english windoz, you will have the nasty surprise of having the GUI display in your locale. That's plain a pain - and easily fixed : delete C:\Program Files (x86)\Git\share\git-gui\lib\msgs\*.msg file(s). Read on all the gory details

Recent versions of git won't allow you  to commit without telling who you are :
git config --global user.name "Firstname Lastname"
git config --global user.email "your_email@youremail.com"
At some point you may need to setup an editor for git - I use notepad++ and a guide for setting this up is here. Essentially you need to issue :

git config --global core.editor C:/path_with_no_spaces/npp.bat

where npp.bat:

#!/bin/sh
"c:/Program Files/Notepad++/notepad++.exe" -multiInst "$*"

notice the Unix like syntax. Alternatively you may just issue :

git config --global core.editor "'C:/Program Files/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin"

Explanation for the flags (you probably only need -multiInst - see here) - another post by VonC with similar info.

At some other point you may need to setup a merge tool - see here for various tools, and here for more up to date info on p4merge.

Git - First-Time Git Setup for more info - I'd say to add these commands in a script and also to dump your %USERPROFILE%/.gitconfig into dropbox and link to it from there

Finally if you are annoyed by the gc popup disable it thusly (but be sure to understand what it is about)

Worth noting : .gitignore, .gitattributes etc start with a dot - you can't create them in explorer - do this in git Bash (for instance) :

$ echo "*.class" >> .gitignore
Another complicated point is to set up the SSH keys (if you want to push without entering your username/pass. You may leave it for now). From here :

Go to Start > Git Gui >

Click the "Generate Key" button.This will generate your public and private OpenSSH keys. You will be prompted to enter an optional passphrase. If you do, then you will be prompted to enter the passphrase each time you try to push to github - so you may wish to leave it blank. Once generated, Git GUI will store your private and public keys in your %USERPROFILE%/.ssh directory. You may wish to back up these keys to somewhere secure. Git GUI will now display your public key. Enter this to your github (or other) account (in github is under Settings > SSH Keys).

Here are some very useful links :

An Illustrated Guide to Git on Windows - really nice demo (with screens) of using the Gui and Bash to commit, branch, push etc. Start from here (I just found the contents)

Basic docs :

Git - Book - be sure to read at least Git - Basic Branching and Merging.
Git Reference - nice minimal site
Git User’s Manual (for version 1.5.3 or newer) - da manual

Couple of links on specific topics - must read :

Git for Computer Scientists - the data structures !
A successful Git branching model - branching done right

More docs tutorials etc :

The Git Parable - lol
Everyday GIT With 20 Commands Or So - quick reference
Git Magic - Preface - and another one
A tour of git: the basics - yet another
Git Immersion - step by step
The Thing About Git - why the index
Git For Windows Developers
A few of my Git tricks, tips and workflows

2013.11.02 20.53 UTC