简体   繁体   中英

git remove commit on the server

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.

您不应删除服务器上的提交,而应还原它们

You can revert the unwanted commits.

git revert commit

This will create another commit that reverts the unwanted changes. After you revert the unwanted commit, you should push to origin.

You can look for --no-commit parameter for reverting also.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM