How to remove commits from a pull request

前端 未结 5 1179
既然无缘
既然无缘 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:24

    If you're removing a commit and don't want to keep its changes @ferit has a good solution.

    If you want to add that commit to the current branch, but doesn't make sense to be part of the current pr, you can do the following instead:

    1. use git rebase -i HEAD~n
    2. Swap the commit you want to remove to the bottom (most recent) position
    3. Save and exit
    4. use git reset HEAD^ --soft to uncommit the changes and get them back in a staged state.
    5. use git push --force to update the remote branch without your removed commit.

    Now you'll have removed the commit from your remote, but will still have the changes locally.

提交回复
热议问题