6 git-replace - Create, list, delete refs to replace objects
11 'git replace' [-f] <object> <replacement>
12 'git replace' [-f] --edit <object>
13 'git replace' [-f] --graft <commit> [<parent>...]
14 'git replace' -d <object>...
15 'git replace' [--format=<format>] [-l [<pattern>]]
19 Adds a 'replace' reference in `refs/replace/` namespace.
21 The name of the 'replace' reference is the SHA-1 of the object that is
22 replaced. The content of the 'replace' reference is the SHA-1 of the
25 The replaced object and the replacement object must be of the same type.
26 This restriction can be bypassed using `-f`.
28 Unless `-f` is given, the 'replace' reference must not yet exist.
30 There is no other restriction on the replaced and replacement objects.
31 Merge commits can be replaced by non-merge commits and vice versa.
33 Replacement references will be used by default by all Git commands
34 except those doing reachability traversal (prune, pack transfer and
37 It is possible to disable use of replacement references for any
38 command using the `--no-replace-objects` option just after 'git'.
40 For example if commit 'foo' has been replaced by commit 'bar':
42 ------------------------------------------------
43 $ git --no-replace-objects cat-file commit foo
44 ------------------------------------------------
46 shows information about commit 'foo', while:
48 ------------------------------------------------
49 $ git cat-file commit foo
50 ------------------------------------------------
52 shows information about commit 'bar'.
54 The 'GIT_NO_REPLACE_OBJECTS' environment variable can be set to
55 achieve the same effect as the `--no-replace-objects` option.
61 If an existing replace ref for the same object exists, it will
62 be overwritten (instead of failing).
66 Delete existing replace refs for the given objects.
69 Edit an object's content interactively. The existing content
70 for <object> is pretty-printed into a temporary file, an
71 editor is launched on the file, and the result is parsed to
72 create a new object of the same type as <object>. A
73 replacement ref is then created to replace <object> with the
74 newly created object. See linkgit:git-var[1] for details about
75 how the editor will be chosen.
77 --graft <commit> [<parent>...]::
78 Create a graft commit. A new commit is created with the same
79 content as <commit> except that its parents will be
80 [<parent>...] instead of <commit>'s parents. A replacement ref
81 is then created to replace <commit> with the newly created
82 commit. See contrib/convert-grafts-to-replace-refs.sh for an
83 example script based on this option that can convert grafts to
88 List replace refs for objects that match the given pattern (or
89 all if no pattern is given).
90 Typing "git replace" without arguments, also lists all replace
94 When listing, use the specified <format>, which can be one of
95 'short', 'medium' and 'long'. When omitted, the format
101 The following format are available:
106 <replaced sha1> -> <replacement sha1>
108 <replaced sha1> (<replaced type>) -> <replacement sha1> (<replacement type>)
110 CREATING REPLACEMENT OBJECTS
111 ----------------------------
113 linkgit:git-filter-branch[1], linkgit:git-hash-object[1] and
114 linkgit:git-rebase[1], among other git commands, can be used to create
115 replacement objects from existing objects. The `--edit` option can
116 also be used with 'git replace' to create a replacement object by
117 editing an existing object.
119 If you want to replace many blobs, trees or commits that are part of a
120 string of commits, you may just want to create a replacement string of
121 commits and then only replace the commit at the tip of the target
122 string of commits with the commit at the tip of the replacement string
127 Comparing blobs or trees that have been replaced with those that
128 replace them will not work properly. And using `git reset --hard` to
129 go back to a replaced commit will move the branch to the replacement
130 commit instead of the replaced commit.
132 There may be other problems when using 'git rev-list' related to
137 linkgit:git-hash-object[1]
138 linkgit:git-filter-branch[1]
139 linkgit:git-rebase[1]
141 linkgit:git-branch[1]
142 linkgit:git-commit[1]
148 Part of the linkgit:git[1] suite