LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

git-update-ref

Safely update Git reference values

TLDR

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

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
copy
sudo dnf install git
copy
sudo pacman -S git
copy
sudo apk add git
copy
sudo zypper install git
copy
brew install git
copy
nix profile install nixpkgs#git
copy

SEE ALSO

RESOURCES

Copied to clipboard
Kai