git pull
以确保您已经更新。
我想回到几天前的提交,并且放弃此后的任何更改。
阅读完整详细答案
,其中将详细说明您可以做什么。git reset
git checkout -b <sha-1>
您可以使用日志命令或git reflog
来实现。
git reflog
git reflog
将显示更新了HEAD
的任何更改,并检查所需的reflog条目将会将HEAD
设置回此提交。
每次修改HEAD都会在reflog
中创建一个新条目。
# print teh git reflog
git reflog
# find out the desired commit (of the index in the reflog)
git checkout HEAD@{...}
git checkout
git checkout
}}# Find out the desired commit which you wish to go back to
# Once you have it checkout the commit to a new branch
git checkout -b <new branch> <commit_id>
git reset
git reset HEAD --hard <commit_id>
"移动"您的头指向所需的提交。
与以前一样,找到所需的提交,然后告诉您的仓库指向该提交。
# read the documentation about the different flavors of the reset (hard/mixed/soft)
git reset HEAD --hard <sha-1>
diff
命令查看哪个文件引起了冲突。 - CodeWizardgit log --follow <path>
。 - CodeWizardgit checkout -b <备份分支>
。现在您可以进行重置,并在推送之前使用diff或pull命令比较分支以验证您要推送的内容。但是,如果您执行重置,则不应有任何差异。 - CodeWizard