Shai Mishali
Shai Mishali

Reputation: 9382

A stubborn issue with git branch merging

There's something I try to do and it always comes down to having to merge different branches manually by resolving conflicts.

The basic kind that always works, is if there is only a single developer working on a branch and then committing the changes,

The problem is - If i have two developers working on different files, how would i merge this two distinct branches into the master branch ? Always when i try i get weird errors from git about fast-forward and such.

I hope my question is clear enough :)

Thanks!

Upvotes: 0

Views: 183

Answers (1)

Marco Ponti
Marco Ponti

Reputation: 2669

First, it may help to post the git output to diagnose the problem more accurately. Assuming your master branch doesn't have any problems or uncommitted files i.e. if you run git status on your master branch you get this:

# On branch master
nothing to commit (working directory clean)

If that is the case you can do a couple of things. You can do:

git checkout master
git merge branch1 branch2

This will most likely use Octopus merge to merge everything into master or you can do it separately if you prefer:

git checkout master
git merge branch1
git merge branch2

This way it will try to fast-forward first. If you still get conflicts then I would post the output here. Also as a general rule, it's a good idea to git merge master while on your working branch (branch1 or branch2) periodically if you're working on a long project to make sure you take care of the conflicts as they happen, although it may be less important with only two developers.

Upvotes: 2

Related Questions