Skip to content

Instantly share code, notes, and snippets.

@timimsms
Created September 21, 2017 08:13
Show Gist options
  • Save timimsms/452f38b9b61eea3e3ed2d47f73d67ce8 to your computer and use it in GitHub Desktop.
Save timimsms/452f38b9b61eea3e3ed2d47f73d67ce8 to your computer and use it in GitHub Desktop.
Stash all branches listed in a provided file to a personal fork.
#!/usr/bin/env bash
#:https://stackoverflow.com/a/10929511
#
# Use: Stashing all branches listed in `to_stash.txt` in remote `timimsms`
#
# > ./git-fork-stash.sh to_stash.txt timimsms
#
[ -z "$1" ] && echo "Warning: No file provided. Exiting" && exit 1
[ -z "$2" ] && echo "Warning: No fork provided. Exiting" && exit 1
echo "Stashing all branches listed in $1 to $2..."
while IFS='' read -r line || [[ -n "$line" ]]; do
git checkout $line;
git pull origin $line;
git push $2 $line;
done < "$1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment