1

I had an awful list of old stashes I have first removed the very old ones

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

I have one huge stash left, which contains many stashed changes. Some are to keep some other would damage my production system. I went through the diff

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

and I know which ones are to keep

I could do

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

to unstash changes on myfilename and is working fine. However, I have a large folder with many files with stashed changes inside. I would like to apply all of them but only within that subfolder.

I have tried to approach it using wildcards in ksh but I does not work

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

results in

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

The solution does not need to be git based, can be a shell script to wrap git calls

00__00__00
  • 4,834
  • 9
  • 41
  • 89

1 Answers1

2

Have you tried :

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

without the ending * ?

Chances are your shell expands myfolder/* before executing the git command, and lists the elements which currently exist on disk, which is probably not what you want.

LeGEC
  • 46,477
  • 5
  • 57
  • 104
  • it does work but then I get a lot of messages like this https://stackoverflow.com/questions/10605405/what-does-each-of-the-y-n-q-a-d-k-j-j-g-e-stand-for-in-context-of-git-p – 00__00__00 Nov 09 '17 at 12:53
  • how to just apply those changes in the stash without dealing with hunks? – 00__00__00 Nov 09 '17 at 12:54
  • @Liborio : if you want to bluntly overwrite all local changes, and replace them with what is stored in `stash@{0}`, just remove the `--patch` option – LeGEC Nov 10 '17 at 13:38