Forked from joeytwiddle/github_get_all_forks.sh
Last active
December 12, 2023 14:04
-
-
Save JanX2/f7fd01bbd37a863cbd0c6c3db6c37ca2 to your computer and use it in GitHub Desktop.
Add all forks of the current repo as remotes
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
#!/usr/bin/env bash | |
set -e | |
# See also: https://github.com/frost-nzcr4/find_forks (same thing but in python) | |
origin_url="$(git config --get remote.origin.url | sed 's+.*: ++')" | |
full_repo_name="$(echo "$origin_url" | sed 's+.*github.com/++ ; s+\.git$++')" | |
forks_url="https://api.github.com/repos/${full_repo_name}/forks" | |
#[ -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 | |
else | |
cat | |
echo | |
echo "Pass -do to execute above commands" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
with pagination
sudo apt-get install jq