Git remove last commits from remote made by someone else

寵の児 提交于 2020-01-15 05:48:25

问题


So, my situation is (by mistake) I have given access to a person to commit to my branch. Now in my local I have made a commit and when I tried to push it to the remote it shows that the remote is ahead. Because the other person has pushed his code to this branch with several commits. Now, can I remove those commits from remote without taking pull to my local?

I tried to do this git push origin +<<commit number>>^:branch

But it says src refspec <<commit number>>^ does not match any.


回答1:


Please try this

git push origin <<branch_name>> -f

In this -f if used for force push

This will remove commits that are made by someone else.



来源:https://stackoverflow.com/questions/37132584/git-remove-last-commits-from-remote-made-by-someone-else

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!