Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to amend the review changes to existing Pull Request [duplicate]

Tags:

git

github

I forked some repo to my profile and then made changes and pushed the changes to my profile under branch name dev_branch. Using this branch, I raised a pull request to source repo's staging branch. The owner now wants some changes to be done before merging. How should I update the pull request to incorporate the requested changes?

Exactly same question asked here : How to update a pull request from forked repo?. But this didn't work for me.

When I try to push to my personal remote repo, I get the following error :

hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

I tried doing a fresh clone and then applying the changes, did git commit --amend and then tried to push git push -u origin dev_branch. Still it gives the same error.

I tried this gist as well : https://gist.github.com/lolindrath/4454638 . Still same error.

What the hell is wrong? Do github really support --amend?

Note : I don't have commit-id in my message, if that matters.

like image 710
Naveen Avatar asked Nov 08 '22 20:11

Naveen


1 Answers

You can make new commits, but you should rebase your branch on top of upstream/master anyway: that way, you make sure your branch is still working on top of the latest from the original repo:

git remote add upstream /url/original/repo
git fetch upstream
git rebase upstream/master

git push --force

You don't have to hesitate to force push: that will update the existing pull request accordingly. See more at "Git - When to use force push".


Think logically, if its a fresh clone, why it needs a pull again.

You don't: you don't need to pull from your fork ('origin').
You need to fetch (not pull) from the original repo (the one you have forked) because by the time you have added your new commits and need to add new ones, the original repo might have evolved on its own.

like image 184
VonC Avatar answered Nov 15 '22 12:11

VonC