{section: Git on Windows} (from drupal {drupalnode: 1434}) {subsection: Install Git} Install Git for Windows from http://code.google.com/p/msysgit/. Note you just want to grab Git, not msysGit. **On Windows you must run:** {code} git config --global core.autocrlf false {endcode} Before you clone This stops git on Windows from changing the line endings. Without this as you clone onto a windows box files are modified when the clone is made. One of the most visible effects of this is patches failing When you clone a repository, you will want to use the following syntax: git clone ssh://tannenba@chevre.cs.wisc.edu/p/condor/repository/CONDOR_SRC.git Since Git includes an ssh.exe in its bin/ directory, you should be good to go -- but you will have to enter your ssh password whenever you git clone/pull/push/fetch, or otherwise do comparisons against the origin. If you want to set things up so you do not have to enter your password each time, read on. {subsection: Setup to use Git without passwords like Todd does} 1: Download plink.exe (google it). This is a nice, free, full-featured command link ssh client for Win32. {link: http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html TJ found it here} 1: Grab puttygen.exe (google it) and use it to create a public/private keypair and add the public key into your authorized keys as instructed {link: http://the.earth.li/~sgtatham/putty/0.58/htmldoc/Chapter8.html#puttygen-pastekey here}. Or {link: http://www.andremolnar.com/how_to_set_up_ssh_keys_with_putty_and_not_get_server_refused_our_key here}. Don't protect your private key with a passphrase; instead, store your keys on your Windows machine in ~/.ssh2 (or wherever) and right select on that folder. Then (at least on XP), click on the _Advanced_ button near the folder Attributes and place a check mark next to _Encrypt contents to secure data_. 1: Logon to whichever machine you ssh into and run the following commands. {code} fs setacl ~/.ssh/ system:anyuser rl stashticket {endcode} The first command changes the access rights of your .ssh folder to be readable by anyone, which is necessary because the remote side of SSH doesn't get a valid AFS token when using public/private keys. Note that this also means that your .bashrc won't execute on the remote machine before the git commands. The second command stashes your current AFS ticket so that =runauth= can use it 1: Test that you can now ssh w/o a password by entering something like: {code} plink.exe -2 -C -i c:\home\tannenba\.ssh2\putty.ppk bob@foobar.edu "/bin/date" {endcode} 1: Now set the GIT_SSH environment variable to be =gitssh.bat=, which is provided below. This batch file will rewrite that command git wants to run so that =runauth= is used (to get an AFS token) and also so that the correct version of Git in /unsup/git is used. {code} @c:\utils\sshcvs\plink.exe -2 -C -i c:\home\tannenba\.ssh2\putty.ppk %1 "/s/std/bin/runauth /unsup/git/bin/%~2" {endcode} 1: You will need to run =stashticket= once a month on whatever machine you ssh into. {subsection: Dealing with the line ending mess like Todd does} Unix machines and our git repo wants to see source terminated with unix-style terminations, aka just a newline. Microsoft dev studio, however, likes to terminate source code with dos-style terminations, aka a carriage-return plus a linefeed. If you aren't careful, when you commit code from windows, you will end up with messy diff that may show all sorts of lines changed that shouldn't be (just because the line termination changed), and unix users may be unhappy because they will see =\r= characters everywhere in the source. Yuck. So what I do is religiously run a batch file (I call it =precommit.bat=) before I add any file into the git index with the =git add= or the =git commit -a= commands. It is safe to run this batch file at any time (running it over and over isn't a problem), but important to run this batch file before adding any files into the index - just running it before you do a commit or push is too late. This batch file essentially parses the output from git status to see figure out a list of modified files, and then it runs =dos2unix.exe= on each file in turn. Here it is: {code} @echo off REM Edit the path on the next line to point into your git clone pushd c:\home\tannenba\condor\CONDOR_SRC git status | findstr /C:"modified: src/" /C:"new file: src/" | sed.exe "s/\//\\/g" | sed.exe "s/modified:/mod ified:/" > %TEMP%\_precom.tmp for /f "tokens=4" %%I in (%TEMP%\_precom.tmp) do (dos2unix.exe "%%I") popd {endcode} You will want to edit the file path at the top of the batch file, make certain environment variable TEMP is set to a writeable subdirectory, and have git.exe, sed.exe, and dos2unix.exe in your path. For sed.exe, a good one to use is the one found in =CONDOR_SRC\msconfig\sed.exe=. For dos2unix.exe, I attached the one I use to this wiki page below.