最新のgitでは、--patchオプションを使用できます
git stash push --patch # since 2.14.6
git stash save --patch # for older git versions
また、git は、ファイルの各変更を stash に追加するかどうかを尋ねます。
あなたはただ答えるyか、n
DOUBLE STASHのUPD
エイリアス:
git config --global alias.stash-staged '!bash -c "git stash --keep-index; git stash push -m "staged" --keep-index; git stash pop stash@{1}"'
これで、ファイルをステージングして実行できますgit stash-staged。
その結果、ステージングされたファイルは stash に保存されます。
ステージングされたファイルを保持したくない場合は、それらを stash に移動します。次に、別のエイリアスを追加して実行できますgit move-staged。
git config --global alias.move-staged '!bash -c "git stash-staged;git commit -m "temp"; git stash; git reset --hard HEAD^; git stash pop"'