Last active
January 3, 2016 03:29
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Revision 2, added .git to the end of the folder, as is convention