import_gist_form_github.sh
· 567 B · Bash
Raw
github_user=user # replace with your GitHub username
opengist_url="http://user:password@opengist.url/init" # replace user, password and Opengist url
curl -s https://api.github.com/users/"$github_user"/gists?per_page=100 | jq '.[] | .git_pull_url' -r | while read url; do
git clone "$url"
repo_dir=$(basename "$url" .git)
# Add remote, push, and remove the directory
if [ -d "$repo_dir" ]; then
cd "$repo_dir"
git remote add gist "$opengist_url"
git push -u gist --all
cd ..
rm -rf "$repo_dir"
fi
done
1 | github_user=user # replace with your GitHub username |
2 | opengist_url="http://user:password@opengist.url/init" # replace user, password and Opengist url |
3 | |
4 | curl -s https://api.github.com/users/"$github_user"/gists?per_page=100 | jq '.[] | .git_pull_url' -r | while read url; do |
5 | git clone "$url" |
6 | repo_dir=$(basename "$url" .git) |
7 | |
8 | # Add remote, push, and remove the directory |
9 | if [ -d "$repo_dir" ]; then |
10 | cd "$repo_dir" |
11 | git remote add gist "$opengist_url" |
12 | git push -u gist --all |
13 | cd .. |
14 | rm -rf "$repo_dir" |
15 | fi |
16 | done |