Search code examples
gitbashcommand-linenantdvcs

Using Git via command line is buggy, but bash works fine?


We're trying to modify out NANT build script to pull changes from our remote Git repository and then publish from a local repository on the build server. While testing out the commands I would need to run I discovered that using Git.exe directly appears to be buggy.

I can do a fetch via the windows command line and it correctly updates the remote branches to point to a newer revision than my local branches. However, when I then try to merge those remote changes into the local branch, it claims I have uncommitted changes and will not let me merge. If I run "status" it tells me I have no changes and it's ready to be fast-forward merged with the remote branch.

If I switch over to the regular Git Bash it works fine. I can fetch and merge all day long with no weird issues about mysterious uncommitted changes that I can't see.


Solution

  • You need to specify work tree when doing the merge:

    git --git-dir=c:\code\klas\.git --work-tree=c:\code\klas merge origin/master
    

    Edit: Just noticed that Charles Bailey mentioned it in a comment and I ensure that I was not trying to kill steal :)