Marko Avlijaš
Marko Avlijaš

Reputation: 1659

How to fix this git merge issue QUICKLY when differences are not important?

I got an unexpected problems with git and I have no idea why or how to fix it.

On branch master
Your branch and 'origin/master' have diverged,
and have 3 and 1 different commit each, respectively.
  (use "git pull" to merge the remote branch into yours)
nothing to commit, working directory clean

What command to should I use to see how branches have diverged?

But more importantly, when I do git pull I get nasty merge conflicts in uglified js files & similar not important files.

I have reset the merge using

git reset --merge

How to resolve that conflict quickly?

Upvotes: 0

Views: 46

Answers (1)

Tom
Tom

Reputation: 4292

You need to start the merge, then resolve the conflicts by checking out either your or their copy of the conflicted files. Then add those files into the commit.

git pull origin master

Then either;

git checkout --ours FILE/PATH

Or;

git checkout --theirs FILE/PATH

Depending on whether you want to use your copy or their copy. My guess is it doesn't matter - as you can now run your build scripts to create correct copies of these files.

Once you've generated your new files, you'll have to add them to the commit;

git add FILE/PATH

Then commit;

git commit -m "Merging remote changes"

Then finally push the changes to your remote;

git push origin master

Edit

In my opinion, if it's worth much, using a default level strategy for conflicts isn't a good idea. Yes - it'll handle your dist or build files - but you could also miss important conflicts in your src files.

It is possible to alter the configuration for your local Repository and set specific merge strategies for specific files.

However I'm unsure if this works with git pull.

To do this, you'll need to create a file in .git/info/attributes with the contents;

FILE/PATH merge=ours

Then you'll need to update your git config;

git config merge.ours.driver true

Now, you shouldn't see these files appear as conflicts.

Upvotes: 1

Related Questions