Git删除其他人的远程提交 [英] Git remove last commits from remote made by someone else

查看:247
本文介绍了Git删除其他人的远程提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我的情况是(错误地)我已经允许一个人提交给我的分支。现在在我的本地我做了一个提交,当我试图将它推送到远程时,它显示远程遥遥领先。因为其他人已经用几次提交将他的代码推送到这个分支。现在,我可以从远程删除那些提交而不需要拉到我的本地吗?



我试图做到这一点 git push origin +<<提交编号>> ^:分支



但它表示 src refspec<< commit number>> ^不匹配任何。

解决方案

请试试这个

  git push origin<< branch_name>> -f 

如果使用 -f for force push



这将删除其他人提交的提交。


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.

解决方案

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.

这篇关于Git删除其他人的远程提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆