smartgit delete commit and return to previous commit

99封情书 提交于 2019-11-30 13:02:59

What you are asking is not specific to SmartGit, but to GIT in general. SmartGit is merely a client, though very convenient and fully featured. In your situation you have to take into account several GIT features:

  1. Branches
  2. Published commits
  3. Detached head
  4. Rewriting remote history

Google on these to get additional info. Now, let's give names to your commits:

You continue to see commit A, because you have a branch pointing on it. This is your local branch master. You can reset this branch to whatever commit you like. In SmartGit to do this, just click down on that green branch label and drag it to any other commit. That's it. E.g. reset it to commit B, where origin/master is pointing to, and you will no longer see this commit in your log, because there is no branch from which it can be reached.

Strictly speaking, you may do the same trick with your origin/master branch, you may reset it to any other commit. But you should be very careful with it, because it points on a commit B, which is published. I.e. anyone may have it pulled on their machine. If you cannot tell for sure, you cannot reset branch from a published commit without danger of breaking someone's copy of the repo.

So the simple answer is you cannot revert the repo to the commit C as you want, because it may conflict with repos cloned on other machines. The longer answer is you can try it.

If you are sure that the only persons that have this repo cloned is you and your colleague, you may rewrite the remote log. For this, reset your local master branch on commit C (with drag&drop, as I told earlier) and push it. SmartGit may forbid you from doing so, go to Preferences/Commands/Push and enable option "Allow modifying pushed commits". Because it is dangerous.

This will rewrite position of remote master branch, pull from it from machine of your colleague. If he did not made any additional changes to this branch, this should be fine.

TLDR: Here is a screenshot of it

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