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

AUTHOR

83       Written by Linus Torvalds <torvalds@osdl.org[1]>.
84

GIT

86       Part of the git(1) suite
87

NOTES

89        1. torvalds@osdl.org
90           mailto:torvalds@osdl.org
91
92
93
94Git 1.7.1                         08/16/2017                 GIT-UPDATE-REF(1)
Impressum