Home Explore Blog CI



git

3rd chunk of `Documentation/git-update-ref.adoc`
60a9d299df4c47f1bc4f9d1d8145ac00e6d4dffb6b6e434f0000000100000d4f
 <old-oid>, if
	given.  If given, <old-oid> may not be zero.

symref-update::
	Set <ref> to <new-target> after verifying <old-target> or <old-oid>,
	if given. Specify a zero <old-oid> to ensure that the ref does not
	exist before the update.

verify::
	Verify <ref> against <old-oid> but do not change it.  If
	<old-oid> is zero or missing, the ref must not exist.

symref-create:
	Create symbolic ref <ref> with <new-target> after verifying that
	it does not exist.

symref-delete::
	Delete <ref> after verifying that it exists with <old-target>, if given.

symref-verify::
	Verify symbolic <ref> against <old-target> but do not change it.
	If <old-target> is missing, the ref must not exist.  Can only be
	used in `no-deref` mode.

option::
	Modify the behavior of the next command naming a <ref>.
	The only valid option is `no-deref` to avoid dereferencing
	a symbolic ref.

start::
	Start a transaction. In contrast to a non-transactional session, a
	transaction will automatically abort if the session ends without an
	explicit commit. This command may create a new empty transaction when
	the current one has been committed or aborted already.

prepare::
	Prepare to commit the transaction. This will create lock files for all
	queued reference updates. If one reference could not be locked, the
	transaction will be aborted.

commit::
	Commit all reference updates queued for the transaction, ending the
	transaction.

abort::
	Abort the transaction, releasing all locks if the transaction is in
	prepared state.

If all <ref>s can be locked with matching <old-oid>s
simultaneously, all modifications are performed.  Otherwise, no
modifications are performed.  Note that while each individual
<ref> is updated or deleted atomically, a concurrent reader may
still see a subset of the modifications.

LOGGING UPDATES
---------------
If config parameter "core.logAllRefUpdates" is true and the ref is one
under "refs/heads/", "refs/remotes/", "refs/notes/", or a pseudoref
like HEAD or ORIG_HEAD; or the file "$GIT_DIR/logs/<ref>" exists then
`git update-ref` will append a line to the log file
"$GIT_DIR/logs/<ref>" (dereferencing all symbolic refs before creating
the log name) describing the change in ref value.  Log lines are
formatted as:

    oldsha1 SP newsha1 SP committer LF

Where "oldsha1" is the 40 character hexadecimal value previously
stored in <ref>, "newsha1" is the 40 character hexadecimal value of
<new-oid> and "committer" is the committer's name, email address
and date in the standard Git committer ident format.

Optionally with -m:

    oldsha1 SP newsha1 SP committer TAB message LF

Where all fields are as described above and "message" is the
value supplied to the -m option.

An update will fail (without changing <ref>) if the current user is
unable to create a new log file, append to the existing log file
or does not have committer information available.

NOTES
-----

Symbolic refs were initially implemented using symbolic links.  This is
now deprecated since not all filesystems support symbolic links.

This command follows *real* symlinks only if they start with "refs/":
otherwise it will just try to read them and update them as a regular
file (i.e. it will allow the filesystem to follow them, but will
overwrite such a symlink to somewhere else with a regular filename).

SEE ALSO
--------
linkgit:git-symbolic-ref[1]

GIT
---
Part of the linkgit:git[1] suite

Title: Git Update Ref Command Details and Logging
Summary
The git update-ref command provides various options for updating references, including verifying old object IDs, creating symbolic refs, and logging updates. The command supports transactions, which can be started, prepared, committed, or aborted, ensuring atomic updates. Additionally, the command logs updates to ref values in log files, providing a record of changes made to refs, and follows specific rules for handling symbolic links and refs.