Anthony G Anthony G - 1 month ago 12
Git Question

git rebase after pull request

I have trouble to update a pull request.

What I did: forked a repository, cloned it locally, created a branch (pr-branch) that tracks upstream/master, committed some changes, pushed to origin, opened a pull request.

Now I need to update my pull request but changes have been made by other devs on upstream/master.

So I did :


  • git checkout -b master-updated upstream/master

  • git pull

  • git checkout pr-branch

  • git rebase master-updated



I was going to make some changes but git/source tree tells me that origin/pr-branch and pr-branch have diverged : 126 ahead and 1 behind

(I did some rebase before but never saw (or paid attention :-)) this kind of message...)

What I am supposed to do next ?

Make changes, commit then push to origin ?
Pull (but create a merge commit I guess), commit then push to origin ?

Thanks!

Answer

Make changes, commit then push to origin ?

Yes, but the push would be a forced one:

git push --force

The goal is to replace the remote history of your pr branch by the local one (rebased on top of the updated upstream master)

126 ahead and 1 behind (I did some rebase before but never saw (or paid attention :-)) this kind of message...)

That seems expected after a rebase: the local and remote history are no longer the same.

Comments