Skip to content

Instantly share code, notes, and snippets.

@aroberts
Created November 22, 2013 16:09
Show Gist options
  • Save aroberts/7602376 to your computer and use it in GitHub Desktop.
Save aroberts/7602376 to your computer and use it in GitHub Desktop.
Git command for moving dirty changes from machine to machine. Takes remote host as the first argument, and remote path as optional second argument (defaults to inferring from current path).
#!/bin/bash
port=22
while getopts "p:" opt; do
case "$opt" in
\?)
echo "bad opt"
exit 1
;;
p) port=$OPTARG
;;
esac
done
shift $((OPTIND-1))
[ "$1" = "--" ] && shift
host=$1
dir=${2:-`echo $PWD | sed "s#^$HOME/##g"`}
ssh -p$port $host "cd \"$dir\" && git diff --no-prefix" | patch -p0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment