LinuxCommandLibrary

git-ls-remote

List remote repository references

TLDR

List remote refs

$ git ls-remote [origin]
copy
Show only tags
$ git ls-remote --tags [origin]
copy
Show only heads
$ git ls-remote --heads [origin]
copy
Show specific ref
$ git ls-remote [origin] [refs/heads/main]
copy
List refs for URL
$ git ls-remote [https://github.com/owner/repo.git]
copy

SYNOPSIS

git ls-remote [options] [repository] [refs]

DESCRIPTION

git ls-remote lists references in a remote repository without downloading any objects. It shows branches, tags, and their commit hashes, useful for checking remote state before fetching.
The command queries the remote directly, showing current refs at query time. This enables checking tag existence, verifying branch status, or scripting against remote repository state. It works with both named remotes and direct URLs.

PARAMETERS

REPOSITORY

Remote name or URL.
REFS
Specific refs to show.
--heads
Show only heads (branches).
--tags
Show only tags.
--refs
Show refs only, no peeled tags.
--get-url
Show remote URL.
--exit-code
Exit with error if no refs found.
--help
Display help information.

CAVEATS

Requires network access. Shows refs at query time. Large repos may have many refs.

HISTORY

git ls-remote is a core Git command for inspecting remote references, useful for automation and verification.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community