top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Pushing files to remote repo I get merge errors on files I have not changed in GIT?

0 votes
301 views

I work on some files and push/merge them to the remote server. Sometimes I get merge conflicts on those files and have to fix them. That's completely fine. I get that.

What I don't understand is that sometimes during this process I will get merge conflicts in files _I have never touched_. In fact they are in a completely different series of directories to the one I am working on and someone else project entirely. How am I meant to know how to fix these? I dont know what the other developer wanted to do and if they have done it right.

I thought git only merged/pushed the files you have changed? If someone else has changed Group A files on the remote repo, why must I change my local Group A files when I am _pushing _completely different set of Group B files?

Sure, Id understand if I were pulling files down to my local and had to resolve merge conflicts then, but this isn't happening when I push the files up.

Any help or advice is much appreciated. Sorry if I sound frustrated - I am really trying hard to get my head round this whole git thing but its just so weird.

posted Dec 20, 2016 by anonymous

Looking for an answer?  Promote on:
Facebook Share Button Twitter Share Button LinkedIn Share Button

Similar Questions
+1 vote

Running on Windows with latest version of Git. 1.9.4. Also had this trouble with 1.8.2 but upgraded hoping it would fix the problem.

When I do a reset on several files, it says they were successfully reverted they still show up as modified when I do a git status. In this case it's just a newline character at the end of the file. I also tried a reset -- hard and they files still show up! What the heck! Help please.

In trying to reproduce this, I re-cloned the git repo from the server, which was in the exact clean state before I started last time. No files have been modified after cloning, all are identical. Then, I created a new branch (totally new, not tracking a remote branch). Viola - I now have these files show up in my git status as modified. Please note that these are files that have been tracked for several previous commits.

Just to clarify - the only command I ran to make this happen is: git checkout -b newbranch

And GitGui shows the files as identical even when compare whitespace is turned on.

+2 votes

In coreboot we try to check for whitespace errors before committing. Of course a pre-commit hook is the way to go, but unfortunately it is not so simple (at least for me) as the following requirements exist.

  1. Only the files actually committed should be checked. That means running git commit -a, abort that and then running git commit some/file should only check some/file for whitespace errors.

  2. There are certain files that are allowed to have whitespace errors. In our case these are *.patch and *.diff files which by design seem to contain whitespace error.

Currently the whole tree is checked, which takes a lot of time. I tried to come up with a patch, but failed so far. Best would be to have

$ git diff --check --only-committed-files --exclude "*patch$"

where I could not find a way for the last to switches.

Currently, I would use

$ git diff-index --cached --name-only $against -- | grep -v patch$

and pass that list to some whitespace check program. Unfortunately that still does not fulfill the first requirement. What am I missing to solve this elegantly?

0 votes

If I create a git repo for multiple projects, for example ALL projects that my team works on, when they clone and pull, do they have to download all the files? Can they sort of selectively download the files they may want to read or work on?
The idea is I want to track a bunch of projects for my team ... so i was thinking to make a repo that contains something like this:

./MyTEAM/./MyTEAM/Project_A/
./MyTEAM/Project_A/Some_Files/
./MyTEAM/Project_A/Some_More_Files/
./MyTEAM/Project_B/
./MyTEAM/Project_C/

Then the entire team can contribute to any of the projects they may be working on, but they should not have to download every single file when they clone .. is that possible?
Basically I do not want to have to create a repo for every single project .. is that what people normally do?

+2 votes

I am getting some unexpected results from a merge and I'd like to understand why.

I have two commits X and Y that I want to merge.

git merge-base X Y # yields B
git diff B X -- F # is empty
git diff B Y -- F # contains the change I want merged
git rev-list X ^B -- F # is empty
git rev-list Y ^B -- F # contains one commit

git checkout X
git merge Y

fails with fixable merge conflicts on other files, but uses X's copy of F instead of Y's. I was expecting it to use Y's copy of F, since only Y has modified F since B. What could cause this?

+2 votes

I posted this question to StackOverflow a while ago but no one answered it so I thought I'd try here.

Let's say I have a file with this content in master:

_____
Line 1
Line 2
Line 3
Line 4 
_____

Now say I create and checkout a new branch called Test. In this branch I change the file to this:

_____
Line 1
Line 2
Line 3 Modified
Line 4 
_____

and I commit this and switch back to master. In master I change the file to:

_____
Line 1
Line 2
Line 3
Line 4 Modified 
_____

and I commit. Now if I merge branch Test into master, I get a conflict.

Why can't git auto resolve this, as those are two entirely independent lines? If I tell git to edit conflicts using BeyondCompare as the difftool, BeyondCompare autoresolves this without even telling the user, since this isn't a real conflict (other merge tools we use at our company do so also). Is there a way to get git to autoresolve these?

I've tried the recursive and resolve merge strategies but neither do it.

It's an issue in our company because there are certain files where multiple developers change lines in close proximity and this causes many unnecessary conflicts when they pull.

...