Skip to content

Instantly share code, notes, and snippets.

@thanhtunguet
Last active November 16, 2019 10:17
Show Gist options
  • Save thanhtunguet/bac5a6b6fc21a6b0ada66cc7fee1e776 to your computer and use it in GitHub Desktop.
Save thanhtunguet/bac5a6b6fc21a6b0ada66cc7fee1e776 to your computer and use it in GitHub Desktop.
Git Sync
#!/bin/bash
function writeHR {
echo '---------------------'
}
function sync {
while read line
do
writeHR;
echo "Checking out $line";
git checkout $line;
git pull $src $line;
git pull $dest $line;
git push $dest $line;
done;
}
cd $1;
echo "You are currently on `realpath .`"
src="$2";
dest="$3";
echo "Fetching remote: $src";
git fetch $src;
echo "Fetching remote: $dest";
git fetch $dest;
git branch -r | grep -v '\->' | grep $src/ | sed "s/$src\///g" | sync
@thanhtunguet
Copy link
Author

thanhtunguet commented Nov 16, 2019

./sync.sh path-to-directory src-remote dest-remote

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment