git-stash如何指定某个文件缓存

July 15, 2026 · Misc #git

git stash如何只缓存某个文件或者挑几个文件缓存

使用 git stash push

在 git 2.13 之后,可以使用下面的命令Ÿ‘‡

git stash push -m "comments" path/to/src/file

使用 git stash --patch or git stash -p

如果使用比较老的git版本,没有太好的方法,就是使用git stash --patch命令,进入交互模式,逐个选择那些加入 you need to interactive mode to check which file need to into the stash workspace 如果不喜欢,那么就升级你的git版本吧!