updated git doc
[TortoiseGit.git] / doc / source / en / TortoiseGit / git_doc / git-update-ref.xml
blob5bcf01ba65316ff7f669f4e44cade10957724645
1 <?xml version="1.0" encoding="UTF-8"?>\r
2 <!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">\r
3 \r
4 <article lang="en" id="git-update-ref(1)">\r
5 <articleinfo>\r
6     <title>git-update-ref(1)</title>\r
7 <indexterm>\r
8 <primary>git-update-ref(1)</primary>\r
9 </indexterm>\r
10 </articleinfo>\r
11 <simplesect id="_name">\r
12 <title>NAME</title>\r
13 <simpara>git-update-ref - Update the object name stored in a ref safely</simpara>\r
14 </simplesect>\r
15 <simplesect id="_synopsis">\r
16 <title>SYNOPSIS</title>\r
17 <blockquote>\r
18 <literallayout><emphasis>git update-ref</emphasis> [-m &lt;reason&gt;] (-d &lt;ref&gt; [&lt;oldvalue&gt;] | [--no-deref] &lt;ref&gt; &lt;newvalue&gt; [&lt;oldvalue&gt;])</literallayout>\r
19 </blockquote>\r
20 </simplesect>\r
21 <simplesect id="_description">\r
22 <title>DESCRIPTION</title>\r
23 <simpara>Given two arguments, stores the &lt;newvalue&gt; in the &lt;ref&gt;, possibly\r
24 dereferencing the symbolic refs.  E.g. <emphasis>git update-ref HEAD\r
25 &lt;newvalue&gt;</emphasis> updates the current branch head to the new object.</simpara>\r
26 <simpara>Given three arguments, stores the &lt;newvalue&gt; in the &lt;ref&gt;,\r
27 possibly dereferencing the symbolic refs, after verifying that\r
28 the current value of the &lt;ref&gt; matches &lt;oldvalue&gt;.\r
29 E.g. <emphasis>git update-ref refs/heads/master &lt;newvalue&gt; &lt;oldvalue&gt;</emphasis>\r
30 updates the master branch head to &lt;newvalue&gt; only if its current\r
31 value is &lt;oldvalue&gt;.  You can specify 40 "0" or an empty string\r
32 as &lt;oldvalue&gt; to make sure that the ref you are creating does\r
33 not exist.</simpara>\r
34 <simpara>It also allows a "ref" file to be a symbolic pointer to another\r
35 ref file by starting with the four-byte header sequence of\r
36 "ref:".</simpara>\r
37 <simpara>More importantly, it allows the update of a ref file to follow\r
38 these symbolic pointers, whether they are symlinks or these\r
39 "regular file symbolic refs".  It follows <emphasis role="strong">real</emphasis> symlinks only\r
40 if they start with "refs/": otherwise it will just try to read\r
41 them and update them as a regular file (i.e. it will allow the\r
42 filesystem to follow them, but will overwrite such a symlink to\r
43 somewhere else with a regular filename).</simpara>\r
44 <simpara>If --no-deref is given, &lt;ref&gt; itself is overwritten, rather than\r
45 the result of following the symbolic pointers.</simpara>\r
46 <simpara>In general, using</simpara>\r
47 <literallayout class="monospaced">git update-ref HEAD "$head"</literallayout>\r
48 <simpara>should be a <emphasis>lot</emphasis> safer than doing</simpara>\r
49 <literallayout class="monospaced">echo "$head" &gt; "$GIT_DIR/HEAD"</literallayout>\r
50 <simpara>both from a symlink following standpoint <emphasis role="strong">and</emphasis> an error checking\r
51 standpoint.  The "refs/" rule for symlinks means that symlinks\r
52 that point to "outside" the tree are safe: they'll be followed\r
53 for reading but not for writing (so we'll never write through a\r
54 ref symlink to some other tree, if you have copied a whole\r
55 archive by creating a symlink tree).</simpara>\r
56 <simpara>With <emphasis>-d</emphasis> flag, it deletes the named &lt;ref&gt; after verifying it\r
57 still contains &lt;oldvalue&gt;.</simpara>\r
58 </simplesect>\r
59 <simplesect id="_logging_updates">\r
60 <title>Logging Updates</title>\r
61 <simpara>If config parameter "core.logAllRefUpdates" is true and the ref is one under\r
62 "refs/heads/", "refs/remotes/", "refs/notes/", or the symbolic ref HEAD; or\r
63 the file "$GIT_DIR/logs/&lt;ref&gt;" exists then <emphasis>git update-ref</emphasis> will append\r
64 a line to the log file "$GIT_DIR/logs/&lt;ref&gt;" (dereferencing all\r
65 symbolic refs before creating the log name) describing the change\r
66 in ref value.  Log lines are formatted as:</simpara>\r
67 <orderedlist numeration="arabic">\r
68 <listitem>\r
69 <simpara>\r
70 oldsha1 SP newsha1 SP committer LF\r
71 </simpara>\r
72 <simpara>Where "oldsha1" is the 40 character hexadecimal value previously\r
73 stored in &lt;ref&gt;, "newsha1" is the 40 character hexadecimal value of\r
74 &lt;newvalue&gt; and "committer" is the committer's name, email address\r
75 and date in the standard GIT committer ident format.</simpara>\r
76 </listitem>\r
77 </orderedlist>\r
78 <simpara>Optionally with -m:</simpara>\r
79 <orderedlist numeration="arabic">\r
80 <listitem>\r
81 <simpara>\r
82 oldsha1 SP newsha1 SP committer TAB message LF\r
83 </simpara>\r
84 <simpara>Where all fields are as described above and "message" is the\r
85 value supplied to the -m option.</simpara>\r
86 </listitem>\r
87 </orderedlist>\r
88 <simpara>An update will fail (without changing &lt;ref&gt;) if the current user is\r
89 unable to create a new log file, append to the existing log file\r
90 or does not have committer information available.</simpara>\r
91 </simplesect>\r
92 <simplesect id="_git">\r
93 <title>GIT</title>\r
94 <simpara>Part of the <xref linkend="git(1)" /> suite</simpara>\r
95 </simplesect>\r
96 </article>\r