This is an old revision of the document!
git on Windows
As of this writing, the official git distribution for Windows is the cygwin version. However, Msysgit is also popular, but Msysgit and cygwin's git won't play nice together without a few tweaks. To avoid any tweaks, you can use cygwin's git for all real work and just have Msysgit for the easy icon display to identify versioning changes.
TortoiseGit
TortoiseGIT is also very popular since TortoiseSVN is considered one of the best clients/addons available for Windows. TortoiseGIT uses msysgit's binary behind the scenes.
I've had the best luck with TortoiseGIT by setting the following:
- Icon Overlays should run in Shell Extended or Shell status cache mode
- make sure AutoCrlf and SafeCrlf are unchecked in Git→Config
- use WinMerge as an external diff viewer (although I like Tortoise as a conflict resolver)
- add a few commonly used items to your Context Menu for quick access
gitshare
It is advisable to set up common paths that both cygwin git and msysgit (and tortoisegit) can clone/pull/push to and from. The best way I've found is to either use ssh entirely (although I haven't tried ssh over tortoise yet), or to make mount points. Mount points involve 3 places:
- in cygwin, we create a mount point by this command in our “~/.profile”. It also is set with noacl so permission errors won't become a problem
mount -f -o binary,posix=0,noacl //unc/or/cygwin/file/path/git /gitshare
- in windows (dos shell), we create a symbolic link at the root of C. This will allow us to put the exact url that we used in cygwin, which in this case is /gitshare/path/to/repo.git (windows/msysgit/tortoisegit will resolve /gitshare to c:\gitshare)
open a dos shell by running as administrator (only administrator can run mklink command) c: cd mklink /D gitshare x:\path\to\git\repo
- lastly, we set up a link in the same way so msysgit can find it when using a bash shell in msysgit
c: cd "Program Files (x86)\Git" (or wherever you installed msysgit) mklink /D gitshare x:\path\to\git\repo
filemode
If you do try to use cygwin git and msysgit together, you may notice the msysgit will identify all files as changed when a project is cloned via cygwin git. This is because cygwin git sets core.filemode = true for each cloned repository. It doesn't even matter if you have filemode = false in your ~/.gitconfig, it will set it based on detected file system capability.
To fix this, you can either remember to set filemode = false in each repo's .git/config file, or use msysgit to clone the project. To edit many .git/config files in a folder containing many working copies, you can use commands like this:
vi `find . -maxdepth 3 -name config`
An easy way to check the status of your configs is to use my gitr script and pipe it with grep like this:
gitr showconfig|grep -E 'showing|filemode'