1git-update-ref(1) 2================= 3 4NAME 5---- 6git-update-ref - update the object name stored in a ref safely 7 8SYNOPSIS 9-------- 10'git-update-ref' [-m <reason>] (-d <ref> <oldvalue> | <ref> <newvalue> [<oldvalue>]) 11 12DESCRIPTION 13----------- 14Given two arguments, stores the <newvalue> in the <ref>, possibly 15dereferencing the symbolic refs. E.g. `git-update-ref HEAD 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>. 21E.g. `git-update-ref refs/heads/master <newvalue> <oldvalue>` 22updates the master branch head to <newvalue> only if its current 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. 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 39In general, using 40 41 git-update-ref HEAD "$head" 42 43should be a _lot_ safer than doing 44 45 echo "$head" > "$GIT_DIR/HEAD" 46 47both from a symlink following standpoint *and* an error checking 48standpoint. The "refs/" rule for symlinks means that symlinks 49that point to "outside" the tree are safe: they'll be followed 50for reading but not for writing (so we'll never write through a 51ref symlink to some other tree, if you have copied a whole 52archive by creating a symlink tree). 53 54With `-d` flag, it deletes the named <ref> after verifying it 55still contains <oldvalue>. 56 57 58Logging Updates 59--------------- 60If config parameter "core.logAllRefUpdates" is true or the file 61"$GIT_DIR/logs/<ref>" exists then `git-update-ref` will append 62a line to the log file "$GIT_DIR/logs/<ref>" (dereferencing all 63symbolic refs before creating the log name) describing the change 64in ref value. Log lines are formatted as: 65 66 . oldsha1 SP newsha1 SP committer LF 67+ 68Where "oldsha1" is the 40 character hexadecimal value previously 69stored in <ref>, "newsha1" is the 40 character hexadecimal value of 70<newvalue> and "committer" is the committer's name, email address 71and date in the standard GIT committer ident format. 72 73Optionally with -m: 74 75 . oldsha1 SP newsha1 SP committer TAB message LF 76+ 77Where all fields are as described above and "message" is the 78value supplied to the -m option. 79 80An update will fail (without changing <ref>) if the current user is 81unable to create a new log file, append to the existing log file 82or does not have committer information available. 83 84Author 85------ 86Written by Linus Torvalds <torvalds@osdl.org>. 87 88GIT 89--- 90Part of the gitlink:git[7] suite