Friday, July 5, 2013

Tips to configure Git in Windows

We were facing the problem with 'EGit- Synchronize workspace' which showed all the files as changed, even if we haven't changed the content of those files. This happened only when we clone/ pull the repository using Git bash (Unix bash prompt). As we all know the reason for this problem - Windows uses both a carriage-return character and a linefeed character for newlines in its files, whereas Linux/ Mac use only the linefeed character.
Git Hub provides some configurations to override these cross-platform issues.
Do the following before cloning the remote repository, I have the folder structure as C:\Git\Project\, where I would clone the repository inside this folder.
  1. Open Git bash at C:\Git\Project\
  2. Enter, git config --system core.autocrlf true and click enter
  3. Enter, git config --system core.whitespace cr-at-eol and click enter
  4. Then clone the repository as usual, git clone 'https://github.com/xxxxx/xxxx.git' 
  5. Then open the local repository in your Eclipse and import projects. 
  6. Right click on your projects > Team > Share to Git
  7. Right click on your projects > Team > Synchronize workspace
  8. In your Team Synchronize perspective, check the list of modified files. No files will be shown.

To know more about the commands that we used in step 2 and 3, refer http://git-scm.com/book/en/Customizing-Git-Git-Configuration

No comments: