问题描述
我不记得我的git local repo是如何进入这种状态的,但这是这种情况:
I don't recall how my git local repo got into this state, but here is the situation:
我在命令行上的状态为什么也没做,工作树干净".
My status on the command line says "nothing to commit, working tree clean".
git stash show -p stash@{0}
显示了一些变化,当我随便滚动浏览(不真正理解git的语言如何工作)时,我看到了我记得在某些函数中编写的特定单词,感到鼓舞,因为我知道我的工作不会丢失.
git stash show -p stash@{0}
shows a diff of some changes, and as I casually scroll through (not really understanding how the language of git works), I see the specific words that I remember writing within certain functions, so I feel encouraged because I know that my work isn't lost.
但是当我运行git stash apply stash@{0}
时,我看到了:
But when I run git stash apply stash@{0}
I see:
CONFLICT (rename/delete): datastore/static/js/app/main.js deleted in Stashed changes and renamed to assets/js/app/helpers/main.js in Updated upstream. Version Updated upstream of assets/js/app/helpers/main.js left in tree.
CONFLICT (rename/delete): datastore/static/js/app/filters.js deleted in Stashed changes and renamed to assets/js/app/helpers/filters.js in Updated upstream. Version Updated upstream of assets/js/app/helpers/filters.js left in tree.
git status
显示:
Unmerged paths:
(use "git restore --staged <file>..." to unstage)
(use "git add <file>..." to mark resolution)
added by us: assets/js/app/helpers/filters.js
added by us: assets/js/app/helpers/main.js
我尝试运行git add .
,但是我的文件没有包含存储中存在的更改.
I tried running git add .
, but then my files didn't contain the changes that existed in the stash.
因此,我重新设置了这种情况(回到什么也没提交,工作树干净"),运行了git stash apply stash@{0}
,然后这次运行了git restore --staged assets/js/app/helpers/*
,结果对我来说似乎没有什么不同(与我运行git add .
的时间相比).
So then I reset the situation (got back to "nothing to commit, working tree clean"), ran git stash apply stash@{0}
, and then this time ran git restore --staged assets/js/app/helpers/*
, and the result doesn't seem any different to me (compared to when I ran git add .
).
在两种情况下,当我检查我的文件时,存储库中都缺少某些关键字.
In both cases, when I inspect my files, certain key words are missing that exist in the stash.
如何恢复工作?
推荐答案
如果您对datastore/static/js/app/main.js
的内容感兴趣,则似乎存储项已存储了删除此文件"操作.您希望恢复的内容可能存储在隐藏之前的提交中.
If you are interested in the content of datastore/static/js/app/main.js
, it looks like the stash has stored the action "delete this file". The content you wish to recover is maybe stored in the commit before the stash.
为了理解我上面写的胡言乱语
To make sense of the gibberish I wrote above :
从终端运行:
git log --oneline --graph stash@{0}
您将看到您的存储区实际上是一个提交(它只是没有存储在您的分支之一中),并且它具有一个父提交(这是您在以下位置的工作状态)某点).
You will see that your stash is actually a commit (it just isn't stored in one of your branches), and that it has a parent commit (which was the state of your work at some point).
您可以在存储中查看文件的全部内容:
You can view the full content of the file in the stash :
git show stash@{0}:datastore/static/js/app/main.js
和父提交"中文件的全部内容. :
and the full content of the file in the "parent commit" :
git show <parentsha1>:datastore/static/js/app/main.js
如果我的猜测是正确的,则第一个"git show"将为空.
If my guess is correct, the first "git show" will be empty.
无论如何,您都可以获取想要的内容:
Anyway, you can get the content you wish :
git checkout <the correct ref> -- datastore/static/js/app/main.js
然后根据需要使用它.
这篇关于如何从git“由我们添加"中恢复重命名后应用隐藏后发生冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!