我把零钱藏起来了。现在,我只想从隐藏中删除一些文件。我该怎么做呢?


当前回答

还有一种方法:

git diff stash@{N}^! -- path/to/file1 path/to/file2  | git apply -R

其他回答

git checkout stash@{N} <File(s)/Folder(s) path> 

如。 若要仅恢复上次存储的./test.c文件和./include文件夹,

git checkout stash@{0} ./test.c ./include

我认为VonC的答案可能是你想要的,但这里有一种方法来做一个选择性的“git apply”:

git show stash@{0}:MyFile.txt > MyFile.txt

为例

git stash show --name-only

结果

ofbiz_src/.project
ofbiz_src/applications/baseaccounting/entitydef/entitymodel_view.xml
ofbiz_src/applications/baselogistics/webapp/baselogistics/delivery/purchaseDeliveryDetail.ftl
ofbiz_src/applications/baselogistics/webapp/baselogistics/transfer/listTransfers.ftl
ofbiz_src/applications/component-load.xml
ofbiz_src/applications/search/config/elasticSearch.properties
ofbiz_src/framework/entity/lib/jdbc/mysql-connector-java-5.1.46.jar
ofbiz_src/framework/entity/lib/jdbc/postgresql-9.3-1101.jdbc4.jar

然后弹出隐藏在特定的文件

git checkout stash@{0} -- ofbiz_src/applications/baselogistics/webapp/baselogistics/delivery/purchaseDeliveryDetail.ftl

其他相关命令

git stash list --stat
get stash show

如果你git隐藏pop(没有冲突),它将删除隐藏后,它被应用。但是如果你git stash apply,它将应用补丁而不从stash列表中删除它。然后你可以用git checkout - files…

还有一种方法:

git diff stash@{N}^! -- path/to/file1 path/to/file2  | git apply -R