Last active
May 16, 2016 08:01
-
-
Save rdebeasi/7cda8f8e638d92cecc81 to your computer and use it in GitHub Desktop.
Simple equivalent of "git stash" for Subversion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This script now lives here: https://github.com/rdebeasi/dotfiles/blob/master/scripts/shelve