2

In the image below, all the files listed by Git are the same exact files that are remote. I used SCP to copy them to BSD for testing before committing. Once the platform tested OK, I committed on another machine:

enter image description here

I can't stress enough that these files are exactly the same, no conflict exists, and there is nothing to merge.

I tried to use git pull -s theirs, but I got an error about non-existent merging strategies.

I can't use git reset --hard HEAD because I have other changes that are in a different phase of testing.

How do I tell Git to stop prompting me about conflicts when none exists?

jww
  • 97,681
  • 90
  • 411
  • 885

2 Answers2

3

Being certain that there are no textual differences in the files doesn't necessarily mean that there are no differences at all and no conflicts isn't the same thing as no differences.

These differences can be anything. Filename case re-mapping (I've seen this when working with code on the non-case-sensitive Apple filesystem) to permission changes, to the difference in line endings between what's in the file and what's expected to differences in file timestamps.

The first thing to start with is always git fetch origin to ensure your local ref store is fully up to date and then git diff origin/branch and look at why git thinks there are differences.

Do this from the terminal and not from an IDE. Depending on which IDE you use, they sometimes silently re-write line endings in the background which will only add to the confusion.

If, as you explain, there are no text differences, it's usually pretty safe to reset back to the origin head but (and there is a caveat), if you have something re-mapping files, perhaps in your git config (altering permissions, changing line-endings, etc.) or filesystem modifying permissions, then there is nothing to prevent this from re-occurring.

Look for what is happening first, then look for why it's happening. Without seeing your git configuration, workflow and difference outputs, it's hard to say with any certainty where the changes are coming from.

mproffitt
  • 2,409
  • 18
  • 24
  • I use `scp` to copy the changed file to different machines for testing. There are no difference between the files. – jww Jul 21 '15 at 10:49
2

If you are certain that the above set of files have no differences versus the remote, then you try resetting each of the files to the HEAD of your branch. After this, you can go a git pull and see what happens. Either the pull will go smoothly, or you could end up with a merge conflict.

git checkout -- algparam.h
git checkout -- basecode.cpp
...
git checkout -- wake.cpp

Followed by what you were already doing:

git pull origin master
Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360
  • Thanks. Is there no switch that says something like, "do a deep inspection to see if there are differences"? I don't use checkout; I use the default workspace. I clone and I go to work. That's because there is one set of sources, and that's the project's copy of the files. Plus, the above adds about 8 extra steps to something that should be a simple process. – jww Jun 29 '15 at 06:31
  • 1
    I would need to see the full workflow of what you did to end up in this state. I am willing to bet that if you did a diff, for example, of `algparam.h` against what was in the remote that there _would_ be a difference. Maybe your IDE added something without you knowing? – Tim Biegeleisen Jun 29 '15 at 06:34