应用子文件夹中的所有隐藏更改

Apply all stashed changes within a subfolder

我有一份糟糕的旧藏品清单 我先删除了非常旧的

git reflog expire --expire-unreachable=7.days refs/stash

我还有一大笔藏品,里面有很多零钱。有些是要保留的,有些会损坏我的生产系统。我经历了差异

git diff stash@{0}^1 stash@{0} 

而且我知道要保留哪些

我可以

git checkout --patch stash@{0} -- myfilename

取消对 myfilename 的更改并且工作正常。 但是,我有一个大文件夹,其中包含许多文件,其中隐藏了更改。我想应用所有这些,但仅限于该子文件夹。

我曾尝试在 ksh 中使用通配符来处理它,但我没有用

    git checkout --patch stash@{0} -- myfolder/*

结果

error pathspec [...] did not match any files known to git

解决方案不需要基于git,可以是shell脚本来包装git调用

你试过了吗:

git checkout --patch stash@{0} -- myfolder

没有结尾 * ?

您的 shell 可能会在执行 git 命令之前扩展 myfolder/*,并列出当前存在于磁盘上的元素,这可能不是你想要的。