简体   繁体   中英

How to `rebase` to avoid duplicated commits on pull request

  1. I did a PR to a repository. Accepted and merged.
  2. I git fetch upstream on my fork.

    [Here starts the stuff I could not understand at all]

  3. I have a commit with a pre compiled message: Merge remote-tracking branch 'upstream/master'

  4. I pushed to my remote

  5. Continue working on another feature, pushed to remote and create another Pull Request where have the (3) commits of the old PR, the merge... commit and the (2 last) commits that are relative to this feature.

Here is the PR, where only the last two commits are necessary.

期望的提交

As you could see, the owner propose to rebase but, sincerely, don't know how to solve it the right way.

You could do :

git rebase -i origin/master

(you can change the origin/master to the branch you want to rebase on)

And then remove the lines of the unnecessary commits in the interactive mode. Then save and git push -f

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