我添加了一个新文件F1并对另一个文件F2进行了更改,但后来又进行了"git reset --hard HEAD ^",我丢失了对文件的所有更改.
有一些方法,我可以让他们回来.
我在这里看了一个相关的问题:如何撤消git reset --hard HEAD~1? 但是,这个问题假设一个人做了一个git提交.
我在提交更改时意外点击了Discard.所以我放弃了整个文件,但我只想丢弃一些大块头.但我没有点击提交,我做了取消.
但现在我无法在我的文件中看到我的代码.
我该怎么办才能撤销该死的丢弃?
提前致谢
我在“合并冲突”阶段丢失了添加到 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 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) 需要一些帮助!
我知道可以使用reflog等来恢复这些更改,但我不知道怎么做!我知道有可能获得差异.我真的需要这些改变.
有任何想法吗??
git ×4
git-reflog ×2
git-add ×1
git-branch ×1
git-index ×1
git-merge ×1
git-pull ×1
git-revert ×1
xcode ×1