25

I have forked my repo, we'll call it repoB from another repo we'll call repoA. Now I don't have permissions to write into repoA.

When I try to create a pull request on repoA to get the latest changes and merge those in to repoB I get a merge conflict error. How do I solve that?

I tried this:

git checkout -b repoA master
git pull https:repoA master

git checkout master
git merge --no-ff repoA
git push origin master

N.B. I cannot checkout forkA as I don't have write permissions on that.

Dave Mackey
  • 4,306
  • 21
  • 78
  • 136
Pritam Banerjee
  • 17,953
  • 10
  • 93
  • 108
  • @AndreasPapadopoulos I can compare a branch from Eclipse Git Tool by just checking out the branch I want to compare to. Here I cannot checkout the master branch of the repo that I forked from, so how do I compare? – Pritam Banerjee Aug 15 '16 at 06:03
  • 1
    Why can't you "checkout the master branch of the repo that I forked from". This is a read-only action. It should work. Maybe you have a different problem. Like you want to check out the branch with a name that you already have checked out (but with a different upstream)? – AnimiVulpis Aug 15 '16 at 08:16

1 Answers1

55

First add the upstream remote

git remote add upstream https://repoA
git fetch upstream

Merge in upstream changes

git checkout master
git merge upstream/master

Resolve conflicts and push

git push origin master

Your pull request should automatically update

Jeff Puckett
  • 37,464
  • 17
  • 118
  • 167
  • I'm having problems with this too but not sure what branch to where. If I created a pull request of branch-x into branch-y and there are conflicts how do i pull the conflicts to local branch-x so i can fix. Any pointers welcome! – v3nt Aug 22 '18 at 14:40
  • 1
    @v3nt you would fetch the remote with branch-y, then merge branch-y into your branch-x which would throw a bunch of conflicts for resolution. when you've solved those, then commit and push up branch-x to update the PR clearing conflicts. – Jeff Puckett Aug 22 '18 at 16:09
  • For those coming here who want to do this in SourceTree, [this SO answer](https://stackoverflow.com/a/13273853/197591) has some good instructions on how to do this. – Neo May 29 '19 at 12:03
  • @JeffPuckett can you write out the commands for that? – Sam Nov 16 '22 at 17:54