如何恢复我提交的更改?

Nof*_*fel 9 git terminal conflict

我正在使用beanstalkapp,我看到一个分支前面的冲突,只是冲突不是很有帮助.但即使我这样做git status,我也没有看到任何说有冲突的东西.任何帮助,以找到我在哪里可以找到文件冲突? 这是仪表板中的图像

Cod*_*ard 6

如果您在服务器端看到冲突,但您没有看到它在您身边 - 您可能有不同的内容.首先git pull从远程服务器做一个确保你是最新的.

我想回到一个提交,几天后回来并丢弃任何事情

Read out this full detailed answer 这将详细解释你能做些什么.

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

  • git reset
  • git checkout -b <sha-1>

如何找出所需的提交?

您可以使用log命令或使用 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@{...}
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述


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>
Run Code Online (Sandbox Code Playgroud)

另一种选择是 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>
Run Code Online (Sandbox Code Playgroud)

现在,您的存储库"返回"到所需的提交.