Curl for Git remotes.
git ls-remote queries a remote's refs over the wire without fetching any objects. Like curl for Git: cheap, scriptable, and works without a working tree.
It is a ref-discovery RPC. The remote streams back its branch and tag list with SHAs; you can filter, sort, and even resolve symbolic refs like HEAD.
git ls-remote [-h] [-t] [--exit-code] [--get-url] [--symref] [--sort=<key>] <remote> [<patterns>...]| Flag | What it does |
|---|---|
<remote> | Remote name or URL (e.g., origin, https://github.com/foo/bar) |
<patterns>... | Glob patterns to filter refs server-side |
-h, --heads | Only show branch refs (refs/heads/*) |
-t, --tags | Only show tag refs (refs/tags/*) |
--exit-code | Exit 2 if no matching refs found — useful in scripts |
--get-url | Print the resolved URL instead of querying; honors insteadOf |
--symref | Show what HEAD (or other symrefs) points to |
--sort=<key> | Sort output by key (e.g., -v:refname for newest tags first) |
git ls-remote origingit ls-remote -h origin 'refs/heads/release/*'git ls-remote --symref origin HEADgit ls-remote -t --sort=-v:refname originHit each option, then Check answers. Score is recorded; Next is always open.