Let’s say you want to work on some code in a git repository. To do this, generally you will “fork” this repository, by cloning it into your own repository. On GitHub there’s a simple “fork” feature that takes care of this. After a while, you might have made some changes, but the original repository that was forked might also have new commits pushed to it. A question many new git users then face is: “How do I pull the upstream changes from the original repository into my own?”
WinMerge as mergetool with Git(Hub) for Windows
WinMerge is a great free tool for merging conflicts when working with a version control system like Git or Subversion. To use it with Git(Hub) follow the following steps:
- Locate your .gitconfig file. If you’re using GitHub for Windows, you will certainly find it in your user folder.
- Add the following text at the bottom of the file:
1234[diff]tool = winmerge[mergetool "winmerge"]cmd = \"C:\\Program Files (x86)\\WinMerge\\WinMergeU.exe\" \"$MERGED\"
If you’re still using a 32-bit version of Windows, Replace “Program Files (x86)” with “Program Files”.
- To merge a conflict, open a shell and browse to your repository’s root folder.
- Use the command
git mergetoolto merge the conflicts with WinMerge.
If WinMerge doesn’t open, Git might still be trying to use a different tool, try again with
git mergetool --tool=winmerge.