Skip to content

Instantly share code, notes, and snippets.

Last active March 19, 2022 17:45
  • Star 5 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Add all forks of the current repo as remotes
#!/usr/bin/env bash
set -e
# See also: (same thing but in python)
origin_url="$(git remote show origin | grep 'Fetch URL:' | sed 's+.*: ++')"
full_repo_name="$(echo "$origin_url" | sed 's+.* ; s+\.git$++')"
#[ -e "forks.json" ] ||
curl -s "${forks_url}" -o forks.json
node -e "
var forks = JSON.parse(fs.readFileSync('forks.json', 'utf-8'));
forks.forEach(forkData => {
console.log('git remote add \"' + forkData.owner.login + '\" \"' + forkData.git_url + '\"');
console.log('git fetch --all');
" |
if [ "$1" = -do ]
then bash
echo "Pass -do to execute above commands"
Copy link

JanX2 commented May 12, 2021

That issue cropped up for me, because git output is localized. The translation doesn’t contain 'Fetch URL:'. The result was an empty "forks.json".

My solution was to replace the screen scraping with git config --get remote.origin.url. That worked.


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