git-ls-remote

List remote repository references

TLDR

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

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.
--symref
Show underlying ref for symbolic refs (e.g. what HEAD points to).
--help
Display help information.

INSTALL

sudo apt install git
sudo dnf install git
sudo pacman -S git
sudo apk add git
sudo zypper install git
brew install git
nix profile install nixpkgs#git

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

git-remote(1), git-fetch(1), git-ls-tree(1)

RESOURCES

Source code · Homepage · Documentation