存储更改,同时将更改保留在Git中的工作目录中 [英] Stash changes while keeping the changes in the working directory in Git
问题描述
是否有一个git stash
命令可以存储您的更改,但也将其保存在工作目录中?那么基本上就是git stash; git stash apply
了吗?
Is there a git stash
command that stashes your changes, but keeps them in the working directory too? So basically a git stash; git stash apply
in one step?
推荐答案
关于它的价值,另一种方法是进行您要保留的更改,然后使用--keep-index
存放所有内容:
For what it's worth, another way to do this is to stage the changes you want to keep, and then stash everything using --keep-index
:
$ git add modified-file.txt
$ git stash push --keep-index
上面的命令将隐藏所有内容,但会将文件保留在您的工作目录中.
The commands above will stash everything, but it will leave the files staged in your working directory.
从官方Linux Kernel Git文档中获得git stash
或来自 git-scm :
如果使用
--keep-index
选项,则已添加到索引的所有更改均保持不变.
If the
--keep-index
option is used, all changes already added to the index are left intact.
这篇关于存储更改,同时将更改保留在Git中的工作目录中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!