Is there a way to fetch the names of refs from a remote in Git without fetching any objects associated with those refs? -
i'm writing script acts on local repo remote repo large, slow, , has many branches divergent histories. typical user cares small number of these branches, i'd save bandwidth not fetching objects branches won't use.
to that, i'd able fetch names of refs remote without fetching actual objects associated refs. (once have names of refs, plan present list user , allow them select branches want, can programmatically build narrow refspec includes branches interesting them.)
is there way in git query remote repo of ref names (in case, few kb) without also incurring cost of fetching of objects (in case, several gb)? (fwiw, users may using either ssh or https urls.)
as far know, git show remote origin
or git ls-remote
can achieve extent. might need filtering or matching want.
the following shown example:
$ git remote show origin * remote origin fetch url: git@10.88.1.128:test push url: git@10.88.1.128:test head branch: master remote branches: client tracked develop tracked index new (next fetch store in remotes/origin) master tracked refs/remotes/origin/masster stale (use 'git remote prune' remove) server tracked test tracked local branches configured 'git pull': masster merges remote masster master merges remote master local ref configured 'git push': master pushes master (local out of date)
the index
branch newly created others , not stored in local.
edit: better example newly created git repository remote url set , nothing else.
git ls-remote
:
$ git init initialized empty git repository in /home/erix/gitrepos/test/.git/ $ git remote add origin git@10.88.1.128:test $ git ls-remote origin 215e658c07c0e667a73ec9247f0b98c90a4fe65a head 4423ed26d1a74139997ed982cf42d681ea4eb248 refs/heads/client 1c3d2c2113d04d7771a5638729528d090d9a2eae refs/heads/develop 8277bdd3d37b9a7c02bead816efabc6849290dc1 refs/heads/index 215e658c07c0e667a73ec9247f0b98c90a4fe65a refs/heads/master eb26276359ae355486536a4bfe5c939a5ab96fb0 refs/heads/server 62018d80b5d279ee2cbe8175a0bde30121288045 refs/heads/test
git remote show
:
$ git remote show origin * remote origin fetch url: git@10.88.1.128:test push url: git@10.88.1.128:test head branch: master remote branches: client new (next fetch store in remotes/origin) develop new (next fetch store in remotes/origin) index new (next fetch store in remotes/origin) master new (next fetch store in remotes/origin) server new (next fetch store in remotes/origin) test new (next fetch store in remotes/origin)
Comments
Post a Comment