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