1

我对文件进行了一些更改并提交了它们。然后我结帐到一个较旧的分支。

之后我发现我所做的所有更改都消失了,我所做的提交也消失了。

如何找到我所做的所有更改?


编辑

这是从我的终端历史记录中复制的:

$ git commit -m 'done clean FNAG Yishu'
[detached HEAD 8a67a04] done clean FNAG Yishu
 3 files changed, 1121 insertions(+)
 create mode 100644 data/data_afterClean/amazon_Revised.txt
 create mode 100644 data/data_afterClean/epinions_Revised.txt
 create mode 100644 data/data_afterClean/slideshare_Revised.txt

但是当我尝试时会发生错误push

$ git push
warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:

  git config --global push.default matching

To squelch this message and adopt the new behavior now, use:

  git config --global push.default simple

See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)

To https://github.com/xxx/xxx.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/xxx/xxx.git'
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. If you did not intend to push that branch, you may want to
hint: specify branches to push or set the 'push.default' configuration variable
hint: to 'simple', 'current' or 'upstream' to push only the current branch.
4

2 回答 2

3

你已经承诺了一个独立的头,而不是一个分支。您可以使用git commit输出中列出的 SHA-1 返回提交:

git checkout 8a67a04

如果您想将此提交保留在分支上,请在结帐后创建:

git checkout -b <branchname>
于 2013-10-21T14:25:04.540 回答
2

提交记录为您提交时所在分支的新提示,因此您可以通过签出该分支来切换回来。

日志始终显示您当前所在分支的历史记录;当 checkout 切换分支时,您不再位于提交提交的分支上,因此不再显示。

于 2013-10-21T13:44:54.170 回答