git删除服务器上的提交 [英] git remove commit on the server

查看:483
本文介绍了git删除服务器上的提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在git中管理我的项目时犯了一些错误:



在这里阅读一些指南和一些帖子我做了这个命令:

  git reset --hard a77ec5f 



<在这之后,这些文件是正确的在我的本地副本,但如果我做了一个 > git status

  $ git status 
#分支开发
#你的分支在4次提交后落后于'origin / dev',并且可以被快速转发。
$
没有提交(工作目录清理)

现在,我可以告诉服务器,我背后的4个提交是要删除吗?
thanks

解决方案

如果您的存储库由其他人同步,那么除非您确定重写历史记录(危险),在本地执行一个空的提交( git commit --allow-empty

/ code>)将HEAD从远程HEAD分离出来,然后 push --force 重写服务器的历史记录。


i've made some mistakes about my project managed in git:

reading some guides and some posts here I made this command:

git reset --hard a77ec5f

where the commint a77ec5f is the last 'good' commit

after this, the files are right in my local copy, but if I do a git status:

$ git status
# On branch dev
# Your branch is behind 'origin/dev' by 4 commits, and can be fast-forwarded.
#
nothing to commit (working directory clean)

and now, how can I tell the server that the 4 commits that I'm behind are to remove? thanks

解决方案

If your repository is synced by others, then you should not push any history changes unless you are certain nobody has pulled the bad changes yet.

To rewrite history (dangerous), do an empty commit locally (git commit --allow-empty) to diverge your HEAD from the remote HEAD, then push --force to rewrite the server's history.

这篇关于git删除服务器上的提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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