Skip to content

Instantly share code, notes, and snippets.

@Gisleburt
Last active January 3, 2016 03:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Gisleburt/54791e2a442444b9ace5 to your computer and use it in GitHub Desktop.
Save Gisleburt/54791e2a442444b9ace5 to your computer and use it in GitHub Desktop.
Usage "source forkops.sh [repo-name]". I wanted to fork opscode community recipes, but forking outside of github is a little difficult so I made this script.
# Credit to sehe
# url: http://stackoverflow.com/questions/5559321/fetch-all-in-a-git-bare-repository-doesnt-synchronize-local-branches-to-the#5559586
dir=$1
if [ "$dir" == "" ] ; then
echo "What are we forking?"
read dir
fi
url=https://github.com/opscode-cookbooks/$dir
git init --bare $dir.git
cd $dir.git
git remote add opscode $url --fetch
git for-each-ref --format='%(refname:short)' -- 'refs/remotes/opscode/' | while read ref; do git branch -t "$(basename "$ref")" "$ref"; done
cd ..
echo "Done"
@Gisleburt
Copy link
Author

Revision 2, added .git to the end of the folder, as is convention

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