git-update-ref

Safely update Git reference values

TLDR

Update ref to new value
$ git update-ref [refs/heads/branch] [commit]
Delete ref
$ git update-ref -d [refs/heads/branch]
Create symbolic ref
$ git update-ref --symbolic-ref [ref] [target]
Update with old value check
$ git update-ref [ref] [new] [old]

SYNOPSIS

git update-ref [options] ref newvalue [oldvalue]

DESCRIPTION

git update-ref safely updates ref names stored in the repository. It provides atomic ref updates with optional old value verification, ensuring that a ref is only changed if it currently points to an expected value.This is a low-level plumbing command used internally by higher-level commands like `git branch` and `git tag`. With --stdin, multiple ref updates can be batched into a single atomic transaction.

PARAMETERS

-d

Delete ref.
--create-reflog
Create reflog.
--no-deref
Don't dereference symbolic.
-m reason
Reflog message.
--stdin
Read update instructions (update, create, delete, verify, symref-update, etc.) from standard input, applying them together as one atomic transaction.
-z
Use NUL-terminated arguments with --stdin instead of quoted, whitespace-terminated strings.
--batch-updates
With --stdin, allow individual updates in the transaction to fail without aborting the others.

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

SEE ALSO

git-symbolic-ref(1), git-branch(1), git-tag(1)

RESOURCES

Documentation · Source code