1git-replace(1) 2============== 3 4NAME 5---- 6git-replace - Create, list, delete refs to replace objects 7 8SYNOPSIS 9-------- 10[verse] 11'git replace' [-f] <object> <replacement> 12'git replace' -d <object>... 13'git replace' -l [<pattern>] 14 15DESCRIPTION 16----------- 17Adds a 'replace' reference in `refs/replace/` namespace. 18 19The name of the 'replace' reference is the SHA-1 of the object that is 20replaced. The content of the 'replace' reference is the SHA-1 of the 21replacement object. 22 23The replaced object and the replacement object must be of the same type. 24This restriction can be bypassed using `-f`. 25 26Unless `-f` is given, the 'replace' reference must not yet exist. 27 28There is no other restriction on the replaced and replacement objects. 29 30Replacement references will be used by default by all Git commands 31except those doing reachability traversal (prune, pack transfer and 32fsck). 33 34It is possible to disable use of replacement references for any 35command using the `--no-replace-objects` option just after 'git'. 36 37For example if commit 'foo' has been replaced by commit 'bar': 38 39------------------------------------------------ 40$ git --no-replace-objects cat-file commit foo 41------------------------------------------------ 42 43shows information about commit 'foo', while: 44 45------------------------------------------------ 46$ git cat-file commit foo 47------------------------------------------------ 48 49shows information about commit 'bar'. 50 51The 'GIT_NO_REPLACE_OBJECTS' environment variable can be set to 52achieve the same effect as the `--no-replace-objects` option. 53 54OPTIONS 55------- 56-f:: 57--force:: 58 If an existing replace ref for the same object exists, it will 59 be overwritten (instead of failing). 60 61-d:: 62--delete:: 63 Delete existing replace refs for the given objects. 64 65-l <pattern>:: 66--list <pattern>:: 67 List replace refs for objects that match the given pattern (or 68 all if no pattern is given). 69 Typing "git replace" without arguments, also lists all replace 70 refs. 71 72CREATING REPLACEMENT OBJECTS 73---------------------------- 74 75linkgit:git-filter-branch[1], linkgit:git-hash-object[1] and 76linkgit:git-rebase[1], among other git commands, can be used to create 77replacement objects from existing objects. 78 79If you want to replace many blobs, trees or commits that are part of a 80string of commits, you may just want to create a replacement string of 81commits and then only replace the commit at the tip of the target 82string of commits with the commit at the tip of the replacement string 83of commits. 84 85BUGS 86---- 87Comparing blobs or trees that have been replaced with those that 88replace them will not work properly. And using `git reset --hard` to 89go back to a replaced commit will move the branch to the replacement 90commit instead of the replaced commit. 91 92There may be other problems when using 'git rev-list' related to 93pending objects. 94 95SEE ALSO 96-------- 97linkgit:git-hash-object[1] 98linkgit:git-filter-branch[1] 99linkgit:git-rebase[1] 100linkgit:git-tag[1] 101linkgit:git-branch[1] 102linkgit:git[1] 103 104GIT 105--- 106Part of the linkgit:git[1] suite