Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why git pull results in thousands of merge conflicts?

Tags:

git

We have a remote repo origin which has master branch, development branch, and a bunch of bugfix branches.

I cloned it to local several months ago, and checkout the development branch but did nothing, then I switched to bugfix_1 branch the other day, and still, did nothing.

Today, I switched back to development branch, and ran git pull, but it resulted in thousands of merge conflicts.

I once thought that git pull is something like svn update, no matter how many files changed on the remote repo, there should no be any merge conflicts since I haven't changed anything locally.

I used to be a svn user, and kind of new in git, it would be very appreciated if someone can provide some explanations, or some possible reasons. Or maybe I was just completely doing something wrong?

Another question is, suppose I'm on development branch, is there any differences between these 2 commands:

git pull

and

git pull origin development

Thank you.

EDIT:

I did git fetch origin and git reset --hard origin/development last week according to Jan's suggestion.

Today, I run git fetch origin and git status, it gives:

Your branch and 'origin/development' have diverged, and have 45 and 51 different commits each, respectively.

I don't know why there're 45 local commits, I don't change anything!

like image 546
gfytd Avatar asked Mar 15 '23 13:03

gfytd


2 Answers

For your first question:

Yes, you're absolutely correct, you should not have any merge conflicts if you didn't change anything. The only possible reason I could imagine is if someone changed the history on the server (which you should never do) instead of only pushing updates to the server.

You can just use whatever is on the server (if you don't have any local changes) by running:

git checkout master
git reset --hard origin/master

For your second question:

Please put it into a separate question on StackOverflow, the two questions don't have anything in common...

like image 54
Jan Rüegg Avatar answered Mar 17 '23 07:03

Jan Rüegg


For your second question:

git pull 

means git fetch origin + git merge origin/development in your case.

git pull origin development

means git fetch origin development + git merge origin/development.

In the second case it fetches only the origin/development branch.

like image 32
Dawn T Cherian Avatar answered Mar 17 '23 07:03

Dawn T Cherian