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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With