Created
November 17, 2011 09:56
-
-
Save tanakahisateru/1372816 to your computer and use it in GitHub Desktop.
Send changed files under Git via SCP (if SSH password auth)
This file contains hidden or 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 | |
if [ $# -ne 1 ]; then | |
echo "$0 <git-commit>" 1>&2 | |
exit 1 | |
fi | |
git diff --name-status $1 | |
read -p "Press any key to execute..." | |
rm -rf ./tmp | |
git diff --name-only $1 | git checkout-index --prefix=./tmp/htdocs/ --stdin | |
git diff --name-status $1 | awk '{if($1=="D") print $2}' > ./tmp/deleted | |
auto_ssh() | |
{ | |
expect -c " | |
spawn $1 | |
expect { | |
\" Are you sure you want to continue connecting (yes/no)?\" { | |
send \"yes\r\" | |
expect \"password:\" | |
send \"${2}\r\" | |
} | |
\"password:\" { | |
send \"${2}\r\" | |
} | |
} | |
interact | |
" | |
} | |
auto_ssh 'scp -r ./tmp/htdocs [email protected]:/home/vhost/www.hostname.com/htdocs' mypassword | |
for line in `cat ./tmp/deleted` | |
do | |
auto_ssh 'ssh [email protected] rm -f /home/vhost/www.hostname.com/htdocs/'$line\' mypassword | |
done |
one liner preserving directory structure: rsync -R $(git ls-files -m) user@ip:dir
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
for just a couple of files:
scp
git ls-files -m
user@ip:dir