gh-clone-org
gh-clone-org copied to clipboard
Does not include other branches?
Hello, at first - that's a wonderful idea and is one of the best ways to back up source code. Thank you for the extension!
But what I've noticed is that, while it pulls all repositories from Organization - it does not include other branches. Most of the active development projects are not in the master/main branch.
If I do git branch - all I see is just the "master", but not other branches. It would be great to have the option that it pulls all branches too.
Or am I missing something?
for i in $(git branch -r | sed 's/^..origin\///' | grep -o '^\S*'); do git checkout $i; git pull; done
It's not an ideal command / can optimize it further at sed and grep but enough for my use case. I hope that can be easily included in this script with a flag "-b" to download all branches from origin too
Technically you do have all the commits once you clone, along with local copies of the remote branches. git checkout just sets up a tracking branch for the local copy of the remote branch (referred to by origin/branch-name).
I actually made this originally to make it easier to run scripts across many repos. For backups it may be better to do something like this:
git clone --mirror "$REPO"
cd "${REPO}.git"
git bundle create "${REPO}.bundle" --all
cp "${REPO}.bundle" "$BACKUP_FOLDER"
Would be nice if this was an explicit option available with the extension