Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to take backup of multiple stash?

Tags:

git

git-stash

I understand that we can use git stash show -p > stash.diff to take backup of a stash.

Now I want to take backup of at least 20 stashes. What's a good way to take backup of all the stashes?

like image 668
mmk Avatar asked Dec 05 '17 11:12

mmk


1 Answers

This snippet will list the IDs of all your existing stashes, and then create separate diff files for each.

for stash in `git stash list | awk -F':' '{print $1}'`
do
    git stash show $stash -p > $stash.diff
done
like image 111
Edmund Dipple Avatar answered Nov 02 '22 03:11

Edmund Dipple