[![Git](https://git-scm.com/images/logo@2x.png)](https://git-scm.com/) --local-branching-on-the-cheap
![](https://git-scm.com/images/dark-mode.svg)
  * [About](https://git-scm.com/about)
    * [Trademark](https://git-scm.com/about/trademark)
  * [Learn](https://git-scm.com/learn)
    * [Book](https://git-scm.com/book)
    * [Cheat Sheet](https://git-scm.com/cheat-sheet)
    * [Videos](https://git-scm.com/videos)
    * [External Links](https://git-scm.com/doc/ext)
  * [Tools](https://git-scm.com/tools)
    * [Command Line](https://git-scm.com/tools/command-line)
    * [GUIs](https://git-scm.com/tools/guis)
    * [Hosting](https://git-scm.com/tools/hosting)
  * [Reference](https://git-scm.com/docs)
  * [Install](https://git-scm.com/install/linux)
  * [Community](https://git-scm.com/community)


  * Table of Contents
    * [NAME](https://git-scm.com/docs/git-refs#_name)
    * [SYNOPSIS](https://git-scm.com/docs/git-refs#_synopsis)
    * [DESCRIPTION](https://git-scm.com/docs/git-refs#_description)
    * [COMMANDS](https://git-scm.com/docs/git-refs#_commands)
    * [OPTIONS](https://git-scm.com/docs/git-refs#_options)
    * [KNOWN LIMITATIONS](https://git-scm.com/docs/git-refs#_known_limitations)
    * [GIT](https://git-scm.com/docs/git-refs#_git)


[ English ▾](https://git-scm.com/docs/git-refs)
Localized versions of **git-refs** manual
  1. [English ](https://git-scm.com/docs/git-refs)

Want to read in your language or fix typos?
[You can help translate this page](https://github.com/jnavila/git-manpages-l10n).
[Topics ▾](https://git-scm.com/docs/git-refs)
### Setup and Config
  * [ git ](https://git-scm.com/docs/git)
  * [ config ](https://git-scm.com/docs/git-config)
  * [ help ](https://git-scm.com/docs/git-help)
  * [ bugreport ](https://git-scm.com/docs/git-bugreport)
  * [ Credential helpers ](https://git-scm.com/doc/credential-helpers)


### Getting and Creating Projects
  * [ init ](https://git-scm.com/docs/git-init)
  * [ clone ](https://git-scm.com/docs/git-clone)


### Basic Snapshotting
  * [ add ](https://git-scm.com/docs/git-add)
  * [ status ](https://git-scm.com/docs/git-status)
  * [ diff ](https://git-scm.com/docs/git-diff)
  * [ commit ](https://git-scm.com/docs/git-commit)
  * [ notes ](https://git-scm.com/docs/git-notes)
  * [ restore ](https://git-scm.com/docs/git-restore)
  * [ reset ](https://git-scm.com/docs/git-reset)
  * [ rm ](https://git-scm.com/docs/git-rm)
  * [ mv ](https://git-scm.com/docs/git-mv)


### Branching and Merging
  * [ branch ](https://git-scm.com/docs/git-branch)
  * [ checkout ](https://git-scm.com/docs/git-checkout)
  * [ switch ](https://git-scm.com/docs/git-switch)
  * [ merge ](https://git-scm.com/docs/git-merge)
  * [ mergetool ](https://git-scm.com/docs/git-mergetool)
  * [ log ](https://git-scm.com/docs/git-log)
  * [ stash ](https://git-scm.com/docs/git-stash)
  * [ tag ](https://git-scm.com/docs/git-tag)
  * [ worktree ](https://git-scm.com/docs/git-worktree)


### Sharing and Updating Projects
  * [ fetch ](https://git-scm.com/docs/git-fetch)
  * [ pull ](https://git-scm.com/docs/git-pull)
  * [ push ](https://git-scm.com/docs/git-push)
  * [ remote ](https://git-scm.com/docs/git-remote)
  * [ submodule ](https://git-scm.com/docs/git-submodule)


### Inspection and Comparison
  * [ show ](https://git-scm.com/docs/git-show)
  * [ log ](https://git-scm.com/docs/git-log)
  * [ diff ](https://git-scm.com/docs/git-diff)
  * [ difftool ](https://git-scm.com/docs/git-difftool)
  * [ range-diff ](https://git-scm.com/docs/git-range-diff)
  * [ shortlog ](https://git-scm.com/docs/git-shortlog)
  * [ describe ](https://git-scm.com/docs/git-describe)


### Patching
  * [ apply ](https://git-scm.com/docs/git-apply)
  * [ cherry-pick ](https://git-scm.com/docs/git-cherry-pick)
  * [ diff ](https://git-scm.com/docs/git-diff)
  * [ rebase ](https://git-scm.com/docs/git-rebase)
  * [ revert ](https://git-scm.com/docs/git-revert)


### Debugging
  * [ bisect ](https://git-scm.com/docs/git-bisect)
  * [ blame ](https://git-scm.com/docs/git-blame)
  * [ grep ](https://git-scm.com/docs/git-grep)


### Email
  * [ am ](https://git-scm.com/docs/git-am)
  * [ apply ](https://git-scm.com/docs/git-apply)
  * [ imap-send ](https://git-scm.com/docs/git-imap-send)
  * [ format-patch ](https://git-scm.com/docs/git-format-patch)
  * [ send-email ](https://git-scm.com/docs/git-send-email)
  * [ request-pull ](https://git-scm.com/docs/git-request-pull)


### External Systems
  * [ svn ](https://git-scm.com/docs/git-svn)
  * [ fast-import ](https://git-scm.com/docs/git-fast-import)


### Server Admin
  * [ daemon ](https://git-scm.com/docs/git-daemon)
  * [ update-server-info ](https://git-scm.com/docs/git-update-server-info)


### Guides
  * [ gitattributes ](https://git-scm.com/docs/gitattributes)
  * [ Command-line interface conventions ](https://git-scm.com/docs/gitcli)
  * [ Everyday Git ](https://git-scm.com/docs/giteveryday)
  * [ Frequently Asked Questions (FAQ) ](https://git-scm.com/docs/gitfaq)
  * [ Glossary ](https://git-scm.com/docs/gitglossary)
  * [ Hooks ](https://git-scm.com/docs/githooks)
  * [ gitignore ](https://git-scm.com/docs/gitignore)
  * [ gitmodules ](https://git-scm.com/docs/gitmodules)
  * [ Revisions ](https://git-scm.com/docs/gitrevisions)
  * [ Submodules ](https://git-scm.com/docs/gitsubmodules)
  * [ Tutorial ](https://git-scm.com/docs/gittutorial)
  * [ Workflows ](https://git-scm.com/docs/gitworkflows)
  * [ All guides... ](https://git-scm.com/docs/git#_guides)


### Administration
  * [ clean ](https://git-scm.com/docs/git-clean)
  * [ gc ](https://git-scm.com/docs/git-gc)
  * [ fsck ](https://git-scm.com/docs/git-fsck)
  * [ reflog ](https://git-scm.com/docs/git-reflog)
  * [ filter-branch ](https://git-scm.com/docs/git-filter-branch)
  * [ instaweb ](https://git-scm.com/docs/git-instaweb)
  * [ archive ](https://git-scm.com/docs/git-archive)
  * [ bundle ](https://git-scm.com/docs/git-bundle)


### Plumbing Commands
  * [ cat-file ](https://git-scm.com/docs/git-cat-file)
  * [ check-ignore ](https://git-scm.com/docs/git-check-ignore)
  * [ checkout-index ](https://git-scm.com/docs/git-checkout-index)
  * [ commit-tree ](https://git-scm.com/docs/git-commit-tree)
  * [ count-objects ](https://git-scm.com/docs/git-count-objects)
  * [ diff-index ](https://git-scm.com/docs/git-diff-index)
  * [ for-each-ref ](https://git-scm.com/docs/git-for-each-ref)
  * [ hash-object ](https://git-scm.com/docs/git-hash-object)
  * [ ls-files ](https://git-scm.com/docs/git-ls-files)
  * [ ls-tree ](https://git-scm.com/docs/git-ls-tree)
  * [ merge-base ](https://git-scm.com/docs/git-merge-base)
  * [ read-tree ](https://git-scm.com/docs/git-read-tree)
  * [ rev-list ](https://git-scm.com/docs/git-rev-list)
  * [ rev-parse ](https://git-scm.com/docs/git-rev-parse)
  * [ show-ref ](https://git-scm.com/docs/git-show-ref)
  * [ symbolic-ref ](https://git-scm.com/docs/git-symbolic-ref)
  * [ update-index ](https://git-scm.com/docs/git-update-index)
  * [ update-ref ](https://git-scm.com/docs/git-update-ref)
  * [ verify-pack ](https://git-scm.com/docs/git-verify-pack)
  * [ write-tree ](https://git-scm.com/docs/git-write-tree)


[ Latest version ▾ ](https://git-scm.com/docs/git-refs) git-refs last updated in 2.52.0
Changes in the **git-refs** manual
  1. 2.53.0 no changes
  2. [2.52.0 ![](https://git-scm.com/images/icons/green-dot.png) ![](https://git-scm.com/images/icons/green-dot.png) ![](https://git-scm.com/images/icons/green-dot.png) ![](https://git-scm.com/images/icons/green-dot.png) ![](https://git-scm.com/images/icons/green-dot.png) ![](https://git-scm.com/images/icons/green-dot.png) ![](https://git-scm.com/images/icons/green-dot.png) ![](https://git-scm.com/images/icons/green-dot.png) ![](https://git-scm.com/images/icons/red-dot.png) ![](https://git-scm.com/images/icons/red-dot.png) ![](https://git-scm.com/images/icons/grey-dot.png) ![](https://git-scm.com/images/icons/grey-dot.png) _2025-11-17_ ](https://git-scm.com/docs/git-refs/2.52.0)
  3. 2.49.1 → 2.51.2 no changes
  4. [2.49.0 ![](https://git-scm.com/images/icons/green-dot.png) ![](https://git-scm.com/images/icons/green-dot.png) ![](https://git-scm.com/images/icons/green-dot.png) ![](https://git-scm.com/images/icons/green-dot.png) ![](https://git-scm.com/images/icons/green-dot.png) ![](https://git-scm.com/images/icons/green-dot.png) ![](https://git-scm.com/images/icons/red-dot.png) ![](https://git-scm.com/images/icons/red-dot.png) ![](https://git-scm.com/images/icons/grey-dot.png) ![](https://git-scm.com/images/icons/grey-dot.png) _2025-03-14_ ](https://git-scm.com/docs/git-refs/2.49.0)
  5. 2.48.1 → 2.48.2 no changes
  6. 2.48.0 no changes
  7. 2.47.1 → 2.47.3 no changes
  8. [2.47.0 ![](https://git-scm.com/images/icons/green-dot.png) ![](https://git-scm.com/images/icons/green-dot.png) ![](https://git-scm.com/images/icons/green-dot.png) ![](https://git-scm.com/images/icons/green-dot.png) ![](https://git-scm.com/images/icons/green-dot.png) ![](https://git-scm.com/images/icons/green-dot.png) ![](https://git-scm.com/images/icons/green-dot.png) ![](https://git-scm.com/images/icons/green-dot.png) ![](https://git-scm.com/images/icons/red-dot.png) ![](https://git-scm.com/images/icons/red-dot.png) ![](https://git-scm.com/images/icons/grey-dot.png) ![](https://git-scm.com/images/icons/grey-dot.png) _2024-10-06_ ](https://git-scm.com/docs/git-refs/2.47.0)
  9. 2.46.1 → 2.46.4 no changes
  10. [2.46.0 ![](https://git-scm.com/images/icons/green-dot.png) ![](https://git-scm.com/images/icons/green-dot.png) ![](https://git-scm.com/images/icons/green-dot.png) ![](https://git-scm.com/images/icons/green-dot.png) ![](https://git-scm.com/images/icons/green-dot.png) ![](https://git-scm.com/images/icons/green-dot.png) ![](https://git-scm.com/images/icons/green-dot.png) ![](https://git-scm.com/images/icons/green-dot.png) ![](https://git-scm.com/images/icons/red-dot.png) ![](https://git-scm.com/images/icons/red-dot.png) ![](https://git-scm.com/images/icons/grey-dot.png) ![](https://git-scm.com/images/icons/grey-dot.png) _2024-07-29_ ](https://git-scm.com/docs/git-refs/2.46.0)


Check your version of git by running
`git --version`
##  [](https://git-scm.com/docs/git-refs#_name)NAME
git-refs - Low-level access to refs
##  [](https://git-scm.com/docs/git-refs#_synopsis)SYNOPSIS
```
git refs migrate --ref-format=_<format>_ [--no-reflog] [--dry-run]
git refs verify [--strict] [--verbose]
git refs list [--count=_<count>_] [--shell|--perl|--python|--tcl]
		   [(--sort=_<key>_)…​] [--format=_<format>_]
		   [--include-root-refs] [--points-at=_<object>_]
		   [--merged[=_<object>_]] [--no-merged[=_<object>_]]
		   [--contains[=_<object>_]] [--no-contains[=_<object>_]]
		   [(--exclude=_<pattern>_)…​] [--start-after=_<marker>_]
		   [ --stdin | (_<pattern>_...)]
git refs exists _<ref>_
git refs optimize [--all] [--no-prune] [--auto] [--include _<pattern>_] [--exclude _<pattern>_]
```

##  [](https://git-scm.com/docs/git-refs#_description)DESCRIPTION
This command provides low-level access to refs.
##  [](https://git-scm.com/docs/git-refs#_commands)COMMANDS

[](https://git-scm.com/docs/git-refs#Documentation/git-refs.txt-migrate)`migrate`

Migrate ref store between different formats.

[](https://git-scm.com/docs/git-refs#Documentation/git-refs.txt-verify)`verify`

Verify reference database consistency.

[](https://git-scm.com/docs/git-refs#Documentation/git-refs.txt-list)list

List references in the repository with support for filtering, formatting, and sorting. This subcommand is an alias for [git-for-each-ref[1]](https://git-scm.com/docs/git-for-each-ref) and offers identical functionality.

[](https://git-scm.com/docs/git-refs#Documentation/git-refs.txt-exists)exists

Check whether the given reference exists. Returns an exit code of 0 if it does, 2 if it is missing, and 1 in case looking up the reference failed with an error other than the reference being missing. This does not verify whether the reference resolves to an actual object.

[](https://git-scm.com/docs/git-refs#Documentation/git-refs.txt-optimize)optimize

Optimizes references to improve repository performance and reduce disk usage. This subcommand is an alias for [git-pack-refs[1]](https://git-scm.com/docs/git-pack-refs) and offers identical functionality.
##  [](https://git-scm.com/docs/git-refs#_options)OPTIONS
The following options are specific to `git` `refs` `migrate`:

[](https://git-scm.com/docs/git-refs#Documentation/git-refs.txt---ref-formatformat)`--ref-format=`_< format>_

The ref format to migrate the ref store to. Can be one of:
  * `files` for loose files with packed-refs. This is the default.
  * `reftable` for the reftable format. This format is experimental and its internals are subject to change.



[](https://git-scm.com/docs/git-refs#Documentation/git-refs.txt---dry-run)`--dry-run`

Perform the migration, but do not modify the repository. The migrated refs will be written into a separate directory that can be inspected separately. The name of the directory will be reported on stdout. This can be used to double check that the migration works as expected before performing the actual migration.

[](https://git-scm.com/docs/git-refs#Documentation/git-refs.txt---reflog)`--reflog`


[](https://git-scm.com/docs/git-refs#Documentation/git-refs.txt---no-reflog)`--no-reflog`

Choose between migrating the reflog data to the new backend, and discarding them. The default is "--reflog", to migrate.
The following options are specific to `git` `refs` `verify`:

[](https://git-scm.com/docs/git-refs#Documentation/git-refs.txt---strict)`--strict`

Enable stricter error checking. This will cause warnings to be reported as errors. See [git-fsck[1]](https://git-scm.com/docs/git-fsck).

[](https://git-scm.com/docs/git-refs#Documentation/git-refs.txt---verbose)`--verbose`

When verifying the reference database consistency, be chatty.
The following options are specific to _git refs list_ :

[](https://git-scm.com/docs/git-refs#Documentation/git-refs.txt-pattern)_< pattern>_...

If one or more _< pattern>_ parameters are given, only refs are shown that match against at least one pattern, either using `fnmatch`(3) or literally, in the latter case matching completely or from the beginning up to a slash.

[](https://git-scm.com/docs/git-refs#Documentation/git-refs.txt---stdin)`--stdin`

The list of patterns is read from standard input instead of from the argument list.

[](https://git-scm.com/docs/git-refs#Documentation/git-refs.txt---countcount)`--count=`_< count>_

Stop after showing _< count>_ refs.

[](https://git-scm.com/docs/git-refs#Documentation/git-refs.txt---sortkey)`--sort=`_< key>_

Sort on the field name _< key>_. Prefix `-` to sort in descending order of the value. When unspecified, `refname` is used. You may use the `--sort=`_< key>_ option multiple times, in which case the last key becomes the primary key.

[](https://git-scm.com/docs/git-refs#Documentation/git-refs.txt---formatformat)`--format`[`=`_< format>_]

A string that interpolates `%`(`fieldname`) from a ref being shown and the object it points at. In addition, the string literal `%%` renders as `%` and `%xx` - where `xx` are hex digits - renders as the character with hex code `xx`. For example, `%00` interpolates to _\0_ (_NUL_), `%09` to _\t_ (_TAB_), and `%0a` to _\n_ (_LF_).
When unspecified, _< format>_ defaults to `%`(`objectname`) `SPC` `%`(`objecttype`) `TAB` `%`(`refname`).

[](https://git-scm.com/docs/git-refs#Documentation/git-refs.txt---colorwhen)`--color`[`=`_< when>_]

Respect any colors specified in the `--format` option. The _< when__ field must be one of `always`, `never`, or `auto` (if _< when>_ is absent, behave as if `always` was given).

[](https://git-scm.com/docs/git-refs#Documentation/git-refs.txt---shell)`--shell`


[](https://git-scm.com/docs/git-refs#Documentation/git-refs.txt---perl)`--perl`


[](https://git-scm.com/docs/git-refs#Documentation/git-refs.txt---python)`--python`


[](https://git-scm.com/docs/git-refs#Documentation/git-refs.txt---tcl)`--tcl`

If given, strings that substitute `%`(`fieldname`) placeholders are quoted as string literals suitable for the specified host language. This is meant to produce a scriptlet that can directly be "eval"ed.

[](https://git-scm.com/docs/git-refs#Documentation/git-refs.txt---points-atobject)`--points-at=`_< object>_

Only list refs which points at the given object.

[](https://git-scm.com/docs/git-refs#Documentation/git-refs.txt---mergedobject)`--merged`[`=`_< object>_]

Only list refs whose tips are reachable from the specified commit (`HEAD` if not specified).

[](https://git-scm.com/docs/git-refs#Documentation/git-refs.txt---no-mergedobject)`--no-merged`[`=`_< object>_]

Only list refs whose tips are not reachable from _< object>_(`HEAD` if not specified).

[](https://git-scm.com/docs/git-refs#Documentation/git-refs.txt---containsobject)`--contains`[`=`_< object>_]

Only list refs which contain _< object>_(`HEAD` if not specified).

[](https://git-scm.com/docs/git-refs#Documentation/git-refs.txt---no-containsobject)`--no-contains`[`=`_< object>_]

Only list refs which don’t contain _< object>_ (`HEAD` if not specified).

[](https://git-scm.com/docs/git-refs#Documentation/git-refs.txt---ignore-case)`--ignore-case`

Sorting and filtering refs are case insensitive.

[](https://git-scm.com/docs/git-refs#Documentation/git-refs.txt---omit-empty)`--omit-empty`

Do not print a newline after formatted refs where the format expands to the empty string.

[](https://git-scm.com/docs/git-refs#Documentation/git-refs.txt---excludeexcluded-pattern)`--exclude=`_< excluded-pattern>_

If one or more `--exclude` options are given, only refs which do not match any _< excluded-pattern>_ parameters are shown. Matching is done using the same rules as _< pattern>_ above.

[](https://git-scm.com/docs/git-refs#Documentation/git-refs.txt---include-root-refs)`--include-root-refs`

List root refs (`HEAD` and pseudorefs) apart from regular refs.

[](https://git-scm.com/docs/git-refs#Documentation/git-refs.txt---start-aftermarker)`--start-after=`_< marker>_

Allows paginating the output by skipping references up to and including the specified marker. When paging, it should be noted that references may be deleted, modified or added between invocations. Output will only yield those references which follow the marker lexicographically. Output begins from the first reference that would come after the marker alphabetically. Cannot be used with `--sort=`_< key>_ or `--stdin` options, or the _< pattern>_ argument(s) to limit the refs.
The following options are specific to _git refs optimize_ :

[](https://git-scm.com/docs/git-refs#Documentation/git-refs.txt---all)--all

The command by default packs all tags and refs that are already packed, and leaves other refs alone. This is because branches are expected to be actively developed and packing their tips does not help performance. This option causes all refs to be packed as well, with the exception of hidden refs, broken refs, and symbolic refs. Useful for a repository with many branches of historical interests.

[](https://git-scm.com/docs/git-refs#Documentation/git-refs.txt---no-prune)--no-prune

The command usually removes loose refs under `$GIT_DIR/refs` hierarchy after packing them. This option tells it not to.

[](https://git-scm.com/docs/git-refs#Documentation/git-refs.txt---auto)--auto

Pack refs as needed depending on the current state of the ref database. The behavior depends on the ref format used by the repository and may change in the future.
  * "files": Loose references are packed into the `packed-refs` file based on the ratio of loose references to the size of the `packed-refs` file. The bigger the `packed-refs` file, the more loose references need to exist before we repack.
  * "reftable": Tables are compacted such that they form a geometric sequence. For two tables N and N+1, where N+1 is newer, this maintains the property that N is at least twice as big as N+1. Only tables that violate this property are compacted.



[](https://git-scm.com/docs/git-refs#Documentation/git-refs.txt---includepattern)--include <pattern>

Pack refs based on a `glob`(`7`) pattern. Repetitions of this option accumulate inclusion patterns. If a ref is both included in `--include` and `--exclude`, `--exclude` takes precedence. Using `--include` will preclude all tags from being included by default. Symbolic refs and broken refs will never be packed. When used with `--all`, it will be a noop. Use `--no-include` to clear and reset the list of patterns.

[](https://git-scm.com/docs/git-refs#Documentation/git-refs.txt---excludepattern)--exclude <pattern>

Do not pack refs matching the given `glob`(`7`) pattern. Repetitions of this option accumulate exclusion patterns. Use `--no-exclude` to clear and reset the list of patterns. If a ref is already packed, including it with `--exclude` will not unpack it.
When used with `--all`, pack only loose refs which do not match any of the provided `--exclude` patterns.
When used with `--include`, refs provided to `--include`, minus refs that are provided to `--exclude` will be packed.
##  [](https://git-scm.com/docs/git-refs#_known_limitations)KNOWN LIMITATIONS
The ref format migration has several known limitations in its current form:
  * It is not possible to migrate repositories that have worktrees.
  * There is no way to block concurrent writes to the repository during an ongoing migration. Concurrent writes can lead to an inconsistent migrated state. Users are expected to block writes on a higher level. If your repository is registered for scheduled maintenance, it is recommended to unregister it first with git-maintenance(1).


These limitations may eventually be lifted.
##  [](https://git-scm.com/docs/git-refs#_git)GIT
Part of the [git[1]](https://git-scm.com/docs/git) suite
### refs
[About this site](https://git-scm.com/site)
Patches, suggestions, and comments are welcome.
Git is a member of [Software Freedom Conservancy](https://git-scm.com/sfc)
