问题描述
我在git中管理我的项目时犯了一些错误:
在这里阅读一些指南和一些帖子我做了这个命令:
git reset --hard a77ec5f
> git status :
$ git status
#分支开发
#你的分支在4次提交后落后于'origin / dev',并且可以被快速转发。
$
没有提交(工作目录清理)
现在,我可以告诉服务器,我背后的4个提交是要删除吗?
thanks
如果您的存储库由其他人同步,那么除非您确定重写历史记录(危险),在本地执行一个空的提交( git commit --allow-empty
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删除服务器上的提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!