How to remove commits from a pull request

前端 未结 5 1180
既然无缘
既然无缘 2020-12-22 16:38

I did a pull request but after that I made some commits to the project locally which ended polluting my pull request, I tried to remove it but without any luck.

I fo

5条回答
  •  我在风中等你
    2020-12-22 17:34

    So do the following ,

    Lets say your branch name is my_branch and this has the extra commits.

    1. git checkout -b my_branch_with_extra_commits (Keeping this branch saved under a different name)
    2. gitk (Opens git console)
    3. Look for the commit you want to keep. Copy the SHA of that commit to a notepad.
    4. git checkout my_branch
    5. gitk (This will open the git console )
    6. Right click on the commit you want to revert to (State before your changes) and click on "reset branch to here"
    7. Do a git pull --rebase origin branch_name_to _merge_to
    8. git cherry-pick

    Now look at the local branch commit history and make sure everything looks good.

提交回复
热议问题