Skip to content

Instantly share code, notes, and snippets.

@kimhunter
Created August 17, 2011 23:24
Show Gist options
  • Save kimhunter/1152903 to your computer and use it in GitHub Desktop.
Save kimhunter/1152903 to your computer and use it in GitHub Desktop.
Export Git stashes
require "yaml"
stash_list = `git stash list`.chomp.split("\n").map {|i| i.chomp }
stash_list.map!{|s|
b = s.match(/stash@\{([0-9]+)\}: (.*)/)
[b[1], b[2]]
}
stash_list.each do |s|
puts "{#{s[0]}}"
`git diff stash@{#{s[0]}} > stashes/#{s[0]}.diff`
end
puts stash_list.to_yaml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment