Skip to content

Instantly share code, notes, and snippets.

@DrewAPicture
Last active August 15, 2016 18:12
Show Gist options
  • Save DrewAPicture/6005193 to your computer and use it in GitHub Desktop.
Save DrewAPicture/6005193 to your computer and use it in GitHub Desktop.
Script to merge a Gist fork into your original. You'll need the id of your Gist and the id of the fork.
#!/bin/bash
# usage: ORIG=###### NEW=###### ./gistmerge.sh
# $ORIG = The Gist ID of your Gist
# $NEW = The Gist ID of the fork
# Note: chmod u+x gistmerge.sh may be necessary
# if you're getting permissions errors
printf "\n\n... Cloning original Gist.\n\n"
git clone git@gist.github.com:$ORIG.git
cd $ORIG
printf "\n\n... Resetting the origin remote.\n\n"
# This is necessary because I have two GitHub accounts
git remote rm origin
git remote add origin git@github-ww:$ORIG.git
printf "\n\n... Adding remote for $NEW\n\n"
git remote add new git@gist.github.com:$NEW.git
printf "... Grabbing fork from $NEW\n\n"
git pull new master
printf "\n\n... Pushing changes to $ORIG\n\n"
git push
cd ..
printf "\n\n... Removing tmp folder\n\n"
rm -rf $ORIG
printf "..\n\n"
printf ".... Done\n\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment