Wednesday, 30 July 2014

Moving your Git working directory from Linux to Windows? There are two issues that you're probably going to get

The simpler solution would be to just check out the repository, but in
some cases you probably have some branches and stashes in your local
repository that you don't want to lose. So if you want to keep your
current local repo, you'll definitely have to deal with these two
issues. Here's how to solve them.

A. The line endings issue. You want to make sure that you're not
inadvertently checking in CRLF line endings.

Make sure you set this:

git config --global core.autocrlf true

This tells Git to use the system's default line ending (CRLF) when
checking out and LF when checking in.

B. File permissions being changed by Cygwin

The executable bit on Git repository files will get changed, and you
will have permissions "changes" in your git respository immediately
after checkout. Fix this by turning git's core.filemode config to
false. Refer to this post:!topic/chromium-dev/0EdNev3NNsw

1. Turn it for globally: git config --global core.filemode false
2. Turn it off for each repo: git config core.filemode false
3. Turn it off for all the submodules of each repo: git submodule
foreach --recursive git config core.filemode false

If you don't change do (B), then when you do 'git status' you'll find it listing a lot of files that have been changed. Then when you do a 'git diff' on one of them, you'll see that the only change was in the executable bit in the permissions, ie

$ git diff scripts/
diff --git a/scripts/ b/scripts/
old mode 100755
new mode 100644