简体   繁体   中英

Git two competitive commits in different branches

I've got the situation:

  1. I was preparing fix for an issue.
  2. I did pull request to upstream remote.
  3. Another person was preparing fix for an issue.
  4. Another person is doing a better fix; their pull request has been accepted.
  5. My pull request is rejected.

What is the best thing I can do now to get back my origin into remote head?

You simply need to fetch origin, and rebase your current branch on top of it.
This could be enough.

git pull --rebase upstream

You might want to checkout another branch than the one you were using for your fix, though, since it doesn't make sense to reapply commits for a fix which has already been accepted (with different commits from a different pull request).

This assumes you have a remote repo address declared in your local repo named 'upstream', refering to the original repo you have forked.
Once you have rebased your work in progress on top of the updated upstream, you can push back to origin (your fork).

在GitHub上分叉

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM