相关疑难解决方法(0)

执行git reset后恢复添加的文件--hard HEAD ^

我添加了一个新文件F1并对另一个文件F2进行了更改,但后来又进行了"git reset --hard HEAD ^",我丢失了对文件的所有更改.

一些方法,我可以让他们回来.

我在这里看了一个相关的问题:如何撤消git reset --hard HEAD~1? 但是,这个问题假设一个人做了一个git提交.

git version-control

59
推荐指数
4
解决办法
4万
查看次数

如果没有提交,如何撤消"丢弃"

我在提交更改时意外点击了Discard.所以我放弃了整个文件,但我只想丢弃一些大块头.但我没有点击提交,我做了取消.

但现在我无法在我的文件中看到我的代码.

我该怎么办才能撤销该死的丢弃?

提前致谢

version-control xcode atlassian-sourcetree

18
推荐指数
3
解决办法
1万
查看次数

恢复 git merge --abort 后删除的 git 文件

我在“合并冲突”阶段丢失了添加到 git 的文件。

一步步:

git pull
git status
Run Code Online (Sandbox Code Playgroud)

Git 告诉我“合并冲突”,没关系。然后我创建一个新文件并将其添加到 git。

vi test.txt
git add test.txt
Run Code Online (Sandbox Code Playgroud)

之后,中止合并:

git merge --abort
Run Code Online (Sandbox Code Playgroud)

我既没有在目录中,也没有通过“git fsck”或“git reflog”找到文件“test.txt”。是否可以恢复文件?

git git-pull git-merge

10
推荐指数
1
解决办法
3332
查看次数

索引是否有更新?

我手头没有特定的问题,但是在过去的某些情况下,我偶然遇到了意外破坏索引的情况,希望我可以返回给定文件的先前状态,该状态在某个时刻被索引了。

一些示例情况是:

$ git add <file>
# find out that I already had an indexed version of <file>,
# and that for some reason I shouldn't have added the extra modifications

$ git stash pop
# find out afterwards that I have a mix of "the index I had"
# and "the index in the stash"

$ git stash
# with an active index, which is now mixed with the state of the working tree

$ git reset <typo>
# …
Run Code Online (Sandbox Code Playgroud)

git git-index git-reflog

5
推荐指数
1
解决办法
297
查看次数

如何恢复添加到git但被checkout覆盖的文件

需要一些帮助!

  1. 我使用"git add"添加了一些文件
  2. 我想检查其他文件,不小心跑了"git checkout -f"

我知道可以使用reflog等来恢复这些更改,但我不知道怎么做!我知道有可能获得差异.我真的需要这些改变.

有任何想法吗??

git git-revert git-add git-branch git-reflog

2
推荐指数
1
解决办法
865
查看次数