How to delete the last n commits on Github and locally?

后端 未结 3 1675
悲&欢浪女
悲&欢浪女 2020-12-04 05:45

I\'m trying to delete the last 2 commits from one of my GitHub repositories. I\'ve tried as suggested here : git push -f origin HEAD^^:master. It seems that it

3条回答
  •  悲哀的现实
    2020-12-04 06:15

    The following works for me

    git reset HEAD~n
    

    It removes the last n commits from local repo, as HEAD^ removes only one. If you need to remove these changes from remote, you might need to force push as you will be behind remote.

    git push -f origin 
    

提交回复
热议问题