I know git stash
, but somehow either I am doing something wrong or my problem is not as common as I think.
我知道git stash,但不知怎的,我要么做错了,要么我的问题不像我想的那么普遍。
Scenario: I am coding, committed and pushed a version, doing further code, then to make a decision I would like to test something. For that, I'd love to save the current local files away and return to that state later on to try another solution. Note: in an intermediate un-committed state. Something one would do normally by zipping the project folder and restoring it later.
场景:我正在编码,提交和推送版本,做更多代码,然后做出决定我想测试一些东西。为此,我希望将当前的本地文件保存起来并稍后返回该状态以尝试其他解决方案。注意:处于中间未提交状态。通过压缩项目文件夹并在以后恢复它可以正常做的事情。
git stash
for me has the crux, that I cannot tell it to simply re-apply the stashed content, ignore anything else, simply recover what was stashed. With git stash apply --force
I get (of course) warnings that files are not committed.
git stash对我来说有关键,我不能告诉它只是重新应用隐藏的内容,忽略其他任何东西,简单地恢复被隐藏的东西。使用git stash apply --force我得到(当然)警告文件未提交。
Any help?
2 个解决方案
#1
1
Use git checkout
instead of git stash apply
:
使用git checkout而不是git stash apply:
$ git checkout stash -- .
This will restore all the files in the current directory to their stashed version.
这会将当前目录中的所有文件还原为其存储版本。
#2
1
If I understand the question correctly you can store all untracked files with git stash --include-untracked
(or git stash -u
for shorten).
如果我正确理解了这个问题,你可以使用git stash存储所有未跟踪的文件--include-untracked(或缩短git stash -u)。
After you finish with the tests just revert the stash with git stash pop
.
完成测试后,只需使用git stash pop恢复存储。
#1
1
Use git checkout
instead of git stash apply
:
使用git checkout而不是git stash apply:
$ git checkout stash -- .
This will restore all the files in the current directory to their stashed version.
这会将当前目录中的所有文件还原为其存储版本。
#2
1
If I understand the question correctly you can store all untracked files with git stash --include-untracked
(or git stash -u
for shorten).
如果我正确理解了这个问题,你可以使用git stash存储所有未跟踪的文件--include-untracked(或缩短git stash -u)。
After you finish with the tests just revert the stash with git stash pop
.
完成测试后,只需使用git stash pop恢复存储。