1GIT-UPDATE-REF(1)                 Git Manual                 GIT-UPDATE-REF(1)
2
3
4

NAME

6       git-update-ref - Update the object name stored in a ref safely
7

SYNOPSIS

9       git update-ref [-m <reason>] (-d <ref> [<oldvalue>] | [--no-deref] <ref> <newvalue> [<oldvalue>])
10
11

DESCRIPTION

13       Given two arguments, stores the <newvalue> in the <ref>, possibly
14       dereferencing the symbolic refs. E.g. git update-ref HEAD <newvalue>
15       updates the current branch head to the new object.
16
17       Given three arguments, stores the <newvalue> in the <ref>, possibly
18       dereferencing the symbolic refs, after verifying that the current value
19       of the <ref> matches <oldvalue>. E.g. git update-ref refs/heads/master
20       <newvalue> <oldvalue> updates the master branch head to <newvalue> only
21       if its current value is <oldvalue>. You can specify 40 "0" or an empty
22       string as <oldvalue> to make sure that the ref you are creating does
23       not exist.
24
25       It also allows a "ref" file to be a symbolic pointer to another ref
26       file by starting with the four-byte header sequence of "ref:".
27
28       More importantly, it allows the update of a ref file to follow these
29       symbolic pointers, whether they are symlinks or these "regular file
30       symbolic refs". It follows real symlinks only if they start with
31       "refs/": otherwise it will just try to read them and update them as a
32       regular file (i.e. it will allow the filesystem to follow them, but
33       will overwrite such a symlink to somewhere else with a regular
34       filename).
35
36       If --no-deref is given, <ref> itself is overwritten, rather than the
37       result of following the symbolic pointers.
38
39       In general, using
40
41           git update-ref HEAD "$head"
42
43       should be a lot safer than doing
44
45           echo "$head" > "$GIT_DIR/HEAD"
46
47       both from a symlink following standpoint and an error checking
48       standpoint. The "refs/" rule for symlinks means that symlinks that
49       point to "outside" the tree are safe: they’ll be followed for reading
50       but not for writing (so we’ll never write through a ref symlink to some
51       other tree, if you have copied a whole archive by creating a symlink
52       tree).
53
54       With -d flag, it deletes the named <ref> after verifying it still
55       contains <oldvalue>.
56

LOGGING UPDATES

58       If config parameter "core.logAllRefUpdates" is true and the ref is one
59       under "refs/heads/", "refs/remotes/", "refs/notes/", or the symbolic
60       ref HEAD; or the file "$GIT_DIR/logs/<ref>" exists then git update-ref
61       will append a line to the log file "$GIT_DIR/logs/<ref>" (dereferencing
62       all symbolic refs before creating the log name) describing the change
63       in ref value. Log lines are formatted as:
64
65        1. oldsha1 SP newsha1 SP committer LF
66
67           Where "oldsha1" is the 40 character hexadecimal value previously
68           stored in <ref>, "newsha1" is the 40 character hexadecimal value of
69           <newvalue> and "committer" is the committer’s name, email address
70           and date in the standard Git committer ident format.
71
72       Optionally with -m:
73
74        1. oldsha1 SP newsha1 SP committer TAB message LF
75
76           Where all fields are as described above and "message" is the value
77           supplied to the -m option.
78
79       An update will fail (without changing <ref>) if the current user is
80       unable to create a new log file, append to the existing log file or
81       does not have committer information available.
82

GIT

84       Part of the git(1) suite
85
86
87
88Git 1.8.3.1                       11/19/2018                 GIT-UPDATE-REF(1)
Impressum