问题描述:

I am working on a git branch that is currently part of a closed pull request on github. Subsequently to the initial pull request, I made some additional commits, pushed those commits to github, and then reverted those commits and recommitted them because I need to revise the commits.

Now if I want to push those commits to github, I'll need to issue a force push: git push --force. But I have the strong feeling that this might cause mayhem with the existing pull request, even though the changed commits occurred after the commits that existed prior to me making the pull request.

Can anyone describe to me how best to handle this situation? I think I may need to just create an entirely new branch and then issue a pull request on that branch instead. But if there's a way to link this to the existing pull request that would be preferable.

网友答案:

If my memory serves me correctly, then if you force push or update the branch in question in any way, GitHub will automatically update the pull request. If doing the force push would result in the pull request not being possible, then GitHub will tell you this.

You do not need to worry about updating the pull request as GitHub will take care of this for you.

This being said, doing a git push --force on any remote branch can cause mayhem for your coworkers who are also currently working on this branch. So you are correct to be shying away from doing a force push, but fortunately a GitHub pull request is not your biggest problem.

网友答案:

The contents of the pull request will be whatever is in the branch that is sent for the pull request. Consequently, when you git push --force, the PR will reflect your revised commit history in the branch that you just pushed to.

网友答案:

Pushing to a branch with existing pull request will update the pull request, it doesn't matter that the commits were done after the pull request.

If you don't want to change the pull request, you should create a new branch and work on it.

相关阅读:
Top