如何恢复到我提交的更改?

How to revert to changes I committed?

我正在使用 beanstalkapp,我看到分支前面有冲突,只是冲突不是很有用。但即使我执行 git status,我也看不到任何表明存在冲突的内容。有什么帮助可以找到我在哪里可以找到冲突的文件吗?

如果您在服务器端看到冲突但在您这边没有看到 - 您可能有不同的内容。首先从远程服务器执行 git pull 以确保您是最新的。

i want to go back to a commit, couple of days back and discard anything after that

这将详细说明您究竟可以做什么。

基本上你有几个选项,但主要选项是:

  • 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

# 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>

现在您的存储库已“返回”所需的提交。