Skip to content

Instantly share code, notes, and snippets.

@glallen01
Last active December 22, 2018 22:35
Show Gist options
  • Save glallen01/b48cfa2c929efa905553309215f68e9d to your computer and use it in GitHub Desktop.
Save glallen01/b48cfa2c929efa905553309215f68e9d to your computer and use it in GitHub Desktop.
zsh to fetch a remote fork as a a branch
# todo, this substitution only works with zsh, and passing shell functions doesn't seem to work with parallel
# usage gfr https://github.com/user/fork.git
gfr() { git remote add ${${1%/*}##*/} $1; git fetch ${${1%/*}##*/} master:${${1%/*}##*/}; }
export -f gfr
function curl -v -H "Authorization: token ${GITHUBAPIKEY}" https://api.github.com/repos/${GITUSER}/${GITREPO}/forks |
jq '.[].clone_url' |
sed "s/\"//g" |
parallel -j 1 ./gfr :::
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment