1GIT-REPLACE(1) Git Manual GIT-REPLACE(1)
2
3
4
6 git-replace - Create, list, delete refs to replace objects
7
9 git replace [-f] <object> <replacement>
10 git replace [-f] --edit <object>
11 git replace [-f] --graft <commit> [<parent>...]
12 git replace [-f] --convert-graft-file
13 git replace -d <object>...
14 git replace [--format=<format>] [-l [<pattern>]]
15
16
18 Adds a replace reference in refs/replace/ namespace.
19
20 The name of the replace reference is the SHA-1 of the object that is
21 replaced. The content of the replace reference is the SHA-1 of the
22 replacement object.
23
24 The replaced object and the replacement object must be of the same
25 type. This restriction can be bypassed using -f.
26
27 Unless -f is given, the replace reference must not yet exist.
28
29 There is no other restriction on the replaced and replacement objects.
30 Merge commits can be replaced by non-merge commits and vice versa.
31
32 Replacement references will be used by default by all Git commands
33 except those doing reachability traversal (prune, pack transfer and
34 fsck).
35
36 It is possible to disable use of replacement references for any command
37 using the --no-replace-objects option just after git.
38
39 For example if commit foo has been replaced by commit bar:
40
41 $ git --no-replace-objects cat-file commit foo
42
43
44 shows information about commit foo, while:
45
46 $ git cat-file commit foo
47
48
49 shows information about commit bar.
50
51 The GIT_NO_REPLACE_OBJECTS environment variable can be set to achieve
52 the same effect as the --no-replace-objects option.
53
55 -f, --force
56 If an existing replace ref for the same object exists, it will be
57 overwritten (instead of failing).
58
59 -d, --delete
60 Delete existing replace refs for the given objects.
61
62 --edit <object>
63 Edit an object’s content interactively. The existing content for
64 <object> is pretty-printed into a temporary file, an editor is
65 launched on the file, and the result is parsed to create a new
66 object of the same type as <object>. A replacement ref is then
67 created to replace <object> with the newly created object. See git-
68 var(1) for details about how the editor will be chosen.
69
70 --raw
71 When editing, provide the raw object contents rather than
72 pretty-printed ones. Currently this only affects trees, which will
73 be shown in their binary form. This is harder to work with, but can
74 help when repairing a tree that is so corrupted it cannot be
75 pretty-printed. Note that you may need to configure your editor to
76 cleanly read and write binary data.
77
78 --graft <commit> [<parent>...]
79 Create a graft commit. A new commit is created with the same
80 content as <commit> except that its parents will be [<parent>...]
81 instead of <commit>'s parents. A replacement ref is then created to
82 replace <commit> with the newly created commit. Use
83 --convert-graft-file to convert a $GIT_DIR/info/grafts file and use
84 replace refs instead.
85
86 --convert-graft-file
87 Creates graft commits for all entries in $GIT_DIR/info/grafts and
88 deletes that file upon success. The purpose is to help users with
89 transitioning off of the now-deprecated graft file.
90
91 -l <pattern>, --list <pattern>
92 List replace refs for objects that match the given pattern (or all
93 if no pattern is given). Typing "git replace" without arguments,
94 also lists all replace refs.
95
96 --format=<format>
97 When listing, use the specified <format>, which can be one of
98 short, medium and long. When omitted, the format defaults to short.
99
101 The following format are available:
102
103 · short: <replaced sha1>
104
105 · medium: <replaced sha1> → <replacement sha1>
106
107 · long: <replaced sha1> (<replaced type>) → <replacement sha1>
108 (<replacement type>)
109
111 git-filter-branch(1), git-hash-object(1) and git-rebase(1), among other
112 git commands, can be used to create replacement objects from existing
113 objects. The --edit option can also be used with git replace to create
114 a replacement object by editing an existing object.
115
116 If you want to replace many blobs, trees or commits that are part of a
117 string of commits, you may just want to create a replacement string of
118 commits and then only replace the commit at the tip of the target
119 string of commits with the commit at the tip of the replacement string
120 of commits.
121
123 Comparing blobs or trees that have been replaced with those that
124 replace them will not work properly. And using git reset --hard to go
125 back to a replaced commit will move the branch to the replacement
126 commit instead of the replaced commit.
127
128 There may be other problems when using git rev-list related to pending
129 objects.
130
132 git-hash-object(1) git-filter-branch(1) git-rebase(1) git-tag(1) git-
133 branch(1) git-commit(1) git-var(1) git(1)
134
136 Part of the git(1) suite
137
138
139
140Git 2.21.0 02/24/2019 GIT-REPLACE(1)