gh-clone-org icon indicating copy to clipboard operation
gh-clone-org copied to clipboard

Does not include other branches?

Open YanDevDe opened this issue 3 years ago • 3 comments
trafficstars

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?

YanDevDe avatar Sep 20 '22 16:09 YanDevDe

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

YanDevDe avatar Sep 20 '22 16:09 YanDevDe

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"

matt-bartel avatar Sep 20 '22 22:09 matt-bartel

Would be nice if this was an explicit option available with the extension

OoLunar avatar Aug 08 '23 00:08 OoLunar