Skip to content

Instantly share code, notes, and snippets.

@rdebeasi rdebeasi/shelve
Last active May 16, 2016

Embed
What would you like to do?
Simple equivalent of "git stash" for Subversion
#!/bin/sh
# Simple equivalent of "git stash" in Subversion.
# This doesn't require creating branches (which can get messy) or using patches
# (which doesn't work if a visual diff tool is configured).
# More ideas: http://stackoverflow.com/q/1554278/925475
# If any comamand fails, abort the script.
set -e
# Feel free to change this path to a directory of your choosing.
shelf=~/Projects/shelf
current_time=$(date "+%Y.%m.%d-%H.%M.%S")
filename=$(basename $1)
new_name=$filename-$current_time
if [ -z "$1" ]; then
echo "Please specify the name of the file to shelve."
else
cp $1 $shelf
# We're copying and *then* renaming rather than just doing one mv command so
# that text editors that have the file open don't start looking at the shelved
# version.
mv $shelf/$filename $shelf/$new_name
echo "Copied '$filename' to '$shelf/$new_name'."
svn revert $1
fi
@rdebeasi

This comment has been minimized.

Copy link
Owner Author

rdebeasi commented Sep 29, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.