1GIT-UPDATE-REF(1) Git Manual GIT-UPDATE-REF(1)
2
3
4
6 git-update-ref - Update the object name stored in a ref safely
7
9 git-update-ref [-m <reason>] (-d <ref> <oldvalue> | [--no-deref] <ref>
10 <newvalue> [<oldvalue>])
11
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
42 git-update-ref HEAD "$head"
43 should be a lot safer than doing
44
45
46 echo "$head" > "$GIT_DIR/HEAD"
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
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
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 Optionally with -m:
72
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 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
83 Written by Linus Torvalds <torvalds@osdl.org>.
84
86 Part of the git(7) suite
87
88
89
90
91Git 1.5.3.3 10/09/2007 GIT-UPDATE-REF(1)