]> git.ipfire.org Git - thirdparty/git.git/blame - Documentation/git-update-ref.txt
Documentation: clearly specify what refs are honored by core.logAllRefUpdates
[thirdparty/git.git] / Documentation / git-update-ref.txt
CommitLineData
12905637
JH
1git-update-ref(1)
2=================
3
4NAME
5----
c3f0baac 6git-update-ref - Update the object name stored in a ref safely
12905637
JH
7
8SYNOPSIS
9--------
b1889c36 10'git update-ref' [-m <reason>] (-d <ref> [<oldvalue>] | [--no-deref] <ref> <newvalue> [<oldvalue>])
12905637
JH
11
12DESCRIPTION
13-----------
14Given two arguments, stores the <newvalue> in the <ref>, possibly
b1889c36 15dereferencing the symbolic refs. E.g. `git update-ref HEAD
12905637
JH
16<newvalue>` updates the current branch head to the new object.
17
18Given three arguments, stores the <newvalue> in the <ref>,
19possibly dereferencing the symbolic refs, after verifying that
20the current value of the <ref> matches <oldvalue>.
b1889c36 21E.g. `git update-ref refs/heads/master <newvalue> <oldvalue>`
12905637 22updates the master branch head to <newvalue> only if its current
ac5409e4
JH
23value is <oldvalue>. You can specify 40 "0" or an empty string
24as <oldvalue> to make sure that the ref you are creating does
25not exist.
12905637
JH
26
27It also allows a "ref" file to be a symbolic pointer to another
28ref file by starting with the four-byte header sequence of
29"ref:".
30
31More importantly, it allows the update of a ref file to follow
32these symbolic pointers, whether they are symlinks or these
33"regular file symbolic refs". It follows *real* symlinks only
34if they start with "refs/": otherwise it will just try to read
35them and update them as a regular file (i.e. it will allow the
36filesystem to follow them, but will overwrite such a symlink to
37somewhere else with a regular filename).
38
68db31cc
SV
39If --no-deref is given, <ref> itself is overwritten, rather than
40the result of following the symbolic pointers.
41
12905637
JH
42In general, using
43
b1889c36 44 git update-ref HEAD "$head"
12905637
JH
45
46should be a _lot_ safer than doing
47
48 echo "$head" > "$GIT_DIR/HEAD"
49
50both from a symlink following standpoint *and* an error checking
51standpoint. The "refs/" rule for symlinks means that symlinks
52that point to "outside" the tree are safe: they'll be followed
53for reading but not for writing (so we'll never write through a
54ref symlink to some other tree, if you have copied a whole
55archive by creating a symlink tree).
56
ac5409e4
JH
57With `-d` flag, it deletes the named <ref> after verifying it
58still contains <oldvalue>.
59
60
6de08ae6
SP
61Logging Updates
62---------------
cd8e3711
BW
63If config parameter "core.logAllRefUpdates" is true and the ref is one under
64"refs/heads/", "refs/remotes/", "refs/notes/", or the symbolic ref HEAD; or
65the file "$GIT_DIR/logs/<ref>" exists then `git update-ref` will append
6de08ae6
SP
66a line to the log file "$GIT_DIR/logs/<ref>" (dereferencing all
67symbolic refs before creating the log name) describing the change
68in ref value. Log lines are formatted as:
69
70 . oldsha1 SP newsha1 SP committer LF
71+
72Where "oldsha1" is the 40 character hexadecimal value previously
73stored in <ref>, "newsha1" is the 40 character hexadecimal value of
74<newvalue> and "committer" is the committer's name, email address
75and date in the standard GIT committer ident format.
76
77Optionally with -m:
78
79 . oldsha1 SP newsha1 SP committer TAB message LF
80+
81Where all fields are as described above and "message" is the
82value supplied to the -m option.
83
84An update will fail (without changing <ref>) if the current user is
85unable to create a new log file, append to the existing log file
86or does not have committer information available.
87
12905637
JH
88Author
89------
90Written by Linus Torvalds <torvalds@osdl.org>.
91
92GIT
93---
9e1f0a85 94Part of the linkgit:git[1] suite