Tuesday, November 24, 2009

git on Windows - files marked as changed because of CLRF? (XP)

Here's something I hope nobody else has to go through: If you're using msysgit to run git on a Windows machine, it defaults to to using CLRF line endings, rather than LF. Left to its own devices, git will "helpfully" convert LFs in files you download to CLRFs. The problem comes when you try to commit back to your *nix repository, and a bunch of files you didn't touch are marked as changed -- or worse, in conflict! Fortunately, there's an easy change. From the msysgit command line, do:

git config --global core.autoclrf false

The discussion I read this from said that's all I'd need to do, but when I did git config --list afterwards to browse my config file, I had two entries for core.autoclrf. One was set to "input" and the other to "false." I went to C:\Program Files\Git\etc, opened gitconfig, and erased the entry set to "input." That fixed it for future cases, but to get rid of all my existing conflicts I had to delete my project and re-clone it.

Start a command-line prompt in a specific directory (XP)

I got tired of doing "cmd, cd" over and over, so I experimented and found a way to open a cmd in a specific directory. Put the following into a batch file:

cd "C:/path/to/dir"
cmd

Throw the batch into C:\WINDOWS\system32 and give it a name. Now you can do Win + R, name, and your cmd will launch, already in the proper directory.