4

I have a PR in a GitHub repository (some one else his PR), which cannot be merged because of conflicts.

What can I do to fix those conflicts by myself?

I tried the following:

  1. Create new branch from PR
  2. Checkout, pull and merge master
  3. Fix the conflicts manually. Lot of work.
  4. Test it locally, it works. :)
  5. Stage all the files git add .
  6. Commit and push
  7. Create a new PR
  8. And then still the message "This branch has conflicts that must be resolved".

What I'm doing wrong? Locally everything works and git status reports:

On branch branch2 Your branch is up-to-date with 'origin/branchX'.

nothing to commit, working directory clean

PS: If I redo "merge master", all the conflicts are back. Don't get this.

Julian
  • 33,915
  • 22
  • 119
  • 174

1 Answers1

4

The usual workflow is:

  • make sure yo have the latest master from upstream, upstream being the name of the remote referencing the original repo in a triangular workflow)

https://cloud.githubusercontent.com/assets/1319791/8943755/5dcdcae4-354a-11e5-9f82-915914fad4f7.png

git fetch upstream

Then you create your own branch (in your own fork, where you have fetch the PR branch from another fork)

git checkout -b branch2 otherfork/PRbranch

And you rebase that branch on top of upstream/master

This is key: no merge: rebase only, that way, you will resolve conflicts, and the resulting history of branch2 will be additional commits on top of upstream/master, which will make the PR a simple fast-forward merge when applied (merged) to master in the original repo (the upstream one).

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Can you explain me why merge isn't working and how I fix my current situation without redoing everything? (current state = merged with master and fixed conflicts, so step 5) – Julian Oct 27 '15 at 12:55
  • @Julian you would still need a rebase, but this time, you can resolve any conflict by keeping your version (http://stackoverflow.com/a/8566376/6309) (actually, keeping "theirs", since a rebase switches ours and theirs: http://stackoverflow.com/a/3052118/6309) – VonC Oct 27 '15 at 12:59