Skip to content

Instantly share code, notes, and snippets.

@sergirf
sergirf / import-multiple-git-repos-to-GitHub
Created January 27, 2022 13:23
run this command from the folder where all the subdirectories with git repositories are and this will create a new github repo for each one and push it all branches, commits and tags. You only have to replace ${GITHUB_ORG} for the actual name or deleted it if no ORG is needed. As a requirement it is using GitHub CLI https://cli.github.com/
for dir in *; do (cd "$dir" && git remote rm origin && gh repo create ${GITHUB_ORG}/"$dir" --private --source=. --remote=origin --push && git push --all && git push --tags); done