推送后还原提交,检查后面的提交和修改文件

revert a commit after push, checkout a commit behind and modification of files

我想还原一个简单的提交,例如c2 已被推送到 mater 分支。当我在 c2 上引入一些错误时,我检查了 c2 后面的一个提交(例如 c1)并修改了文件。现在我的应用程序运行良好,我只想提交并推送当前文件。但我不能,因为我不在任何分支机构。

* (no branch)
  master
  remotes/origin/HEAD -> origin/master
  remotes/origin/master

我想确定我该怎么做。

您可能不想重写推送分支的历史记录。那么最简单的方法就是显式还原:

 git checkout master
 git revert c2 #will create a new commit which would effectively negate your c2
 git push origin mater