I have an old shell snippet that I use (or to its alias) often that updates all the repos in a folder.
find . -maxdepth 1 -type d -exec sh -c '(cd {} && git checkout master && git pull)' ';'
However, today many repos are converting to use main
rather than master
. In particular, GitHub now defaults to that. But there are still many repos that still use master
.
I'm seeking a generic linux/macOS not-only-on-github replacement snippet (that I can alias) to checkout the correct branch (I'm willing to presume there is not both types) and pull.
That being said, if someone has a version of this that works with GitHub's gh
tool, that would be useful. But I do need one that works outside of GitHub.
Another optional feature that I'd love is if the script can do the right thing if the max-depth 1
repo explicitly has submodules.
Related other Stack Overflow questions: