6 git-replace - Create, list, delete refs to replace objects
11 'git replace' [-f] <object> <replacement>
12 'git replace' -d <object>...
13 'git replace' -l [<pattern>]
17 Adds a 'replace' reference in `refs/replace/` namespace.
19 The name of the 'replace' reference is the SHA-1 of the object that is
20 replaced. The content of the 'replace' reference is the SHA-1 of the
23 The replaced object and the replacement object must be of the same type.
24 This restriction can be bypassed using `-f`.
26 Unless `-f` is given, the 'replace' reference must not yet exist.
28 There is no other restriction on the replaced and replacement objects.
29 Merge commits can be replaced by non-merge commits and vice versa.
31 Replacement references will be used by default by all Git commands
32 except those doing reachability traversal (prune, pack transfer and
35 It is possible to disable use of replacement references for any
36 command using the `--no-replace-objects` option just after 'git'.
38 For example if commit 'foo' has been replaced by commit 'bar':
40 ------------------------------------------------
41 $ git --no-replace-objects cat-file commit foo
42 ------------------------------------------------
44 shows information about commit 'foo', while:
46 ------------------------------------------------
47 $ git cat-file commit foo
48 ------------------------------------------------
50 shows information about commit 'bar'.
52 The 'GIT_NO_REPLACE_OBJECTS' environment variable can be set to
53 achieve the same effect as the `--no-replace-objects` option.
59 If an existing replace ref for the same object exists, it will
60 be overwritten (instead of failing).
64 Delete existing replace refs for the given objects.
68 List replace refs for objects that match the given pattern (or
69 all if no pattern is given).
70 Typing "git replace" without arguments, also lists all replace
73 CREATING REPLACEMENT OBJECTS
74 ----------------------------
76 linkgit:git-filter-branch[1], linkgit:git-hash-object[1] and
77 linkgit:git-rebase[1], among other git commands, can be used to create
78 replacement objects from existing objects.
80 If you want to replace many blobs, trees or commits that are part of a
81 string of commits, you may just want to create a replacement string of
82 commits and then only replace the commit at the tip of the target
83 string of commits with the commit at the tip of the replacement string
88 Comparing blobs or trees that have been replaced with those that
89 replace them will not work properly. And using `git reset --hard` to
90 go back to a replaced commit will move the branch to the replacement
91 commit instead of the replaced commit.
93 There may be other problems when using 'git rev-list' related to
98 linkgit:git-hash-object[1]
99 linkgit:git-filter-branch[1]
100 linkgit:git-rebase[1]
102 linkgit:git-branch[1]
107 Part of the linkgit:git[1] suite