Skip to content

Instantly share code, notes, and snippets.

@RickyCook
Last active August 29, 2015 14:13
Show Gist options
  • Save RickyCook/c0ea491eac1fd65b4b09 to your computer and use it in GitHub Desktop.
Save RickyCook/c0ea491eac1fd65b4b09 to your computer and use it in GitHub Desktop.
Rsync a git repo to its remote. For when you want to sync, but not commit
#!/bin/bash
remote_name="$1"
: ${remote_name:="origin"}
git_root="$(cd "$(git rev-parse --show-toplevel)"; pwd)/"
rsync_dest=$(git remote -v | grep "^$remote_name\s.*\(push\)" | awk '{print $2}')
echo "Remote name: $remote_name"
echo "Repo root: $git_root"
echo "Repo dest: $rsync_dest"
rsync -zr --progress --exclude .git "$git_root" "$rsync_dest"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment