1GIT-REPLACE(1)                    Git Manual                    GIT-REPLACE(1)
2
3
4

NAME

6       git-replace - Create, list, delete refs to replace objects
7

SYNOPSIS

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

DESCRIPTION

17       Adds a replace reference in refs/replace/ namespace.
18
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
21       replacement object.
22
23       The replaced object and the replacement object must be of the same
24       type. This restriction can be bypassed using -f.
25
26       Unless -f is given, the replace reference must not yet exist.
27
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.
30
31       Replacement references will be used by default by all Git commands
32       except those doing reachability traversal (prune, pack transfer and
33       fsck).
34
35       It is possible to disable use of replacement references for any command
36       using the --no-replace-objects option just after git.
37
38       For example if commit foo has been replaced by commit bar:
39
40           $ git --no-replace-objects cat-file commit foo
41
42       shows information about commit foo, while:
43
44           $ git cat-file commit foo
45
46       shows information about commit bar.
47
48       The GIT_NO_REPLACE_OBJECTS environment variable can be set to achieve
49       the same effect as the --no-replace-objects option.
50

OPTIONS

52       -f, --force
53           If an existing replace ref for the same object exists, it will be
54           overwritten (instead of failing).
55
56       -d, --delete
57           Delete existing replace refs for the given objects.
58
59       --edit <object>
60           Edit an object’s content interactively. The existing content for
61           <object> is pretty-printed into a temporary file, an editor is
62           launched on the file, and the result is parsed to create a new
63           object of the same type as <object>. A replacement ref is then
64           created to replace <object> with the newly created object. See git-
65           var(1) for details about how the editor will be chosen.
66
67       --raw
68           When editing, provide the raw object contents rather than
69           pretty-printed ones. Currently this only affects trees, which will
70           be shown in their binary form. This is harder to work with, but can
71           help when repairing a tree that is so corrupted it cannot be
72           pretty-printed. Note that you may need to configure your editor to
73           cleanly read and write binary data.
74
75       --graft <commit> [<parent>...]
76           Create a graft commit. A new commit is created with the same
77           content as <commit> except that its parents will be [<parent>...]
78           instead of <commit>'s parents. A replacement ref is then created to
79           replace <commit> with the newly created commit. Use
80           --convert-graft-file to convert a $GIT_DIR/info/grafts file and use
81           replace refs instead.
82
83       --convert-graft-file
84           Creates graft commits for all entries in $GIT_DIR/info/grafts and
85           deletes that file upon success. The purpose is to help users with
86           transitioning off of the now-deprecated graft file.
87
88       -l <pattern>, --list <pattern>
89           List replace refs for objects that match the given pattern (or all
90           if no pattern is given). Typing "git replace" without arguments,
91           also lists all replace refs.
92
93       --format=<format>
94           When listing, use the specified <format>, which can be one of
95           short, medium and long. When omitted, the format defaults to short.
96

FORMATS

98       The following format are available:
99
100       ·   short: <replaced sha1>
101
102       ·   medium: <replaced sha1> → <replacement sha1>
103
104       ·   long: <replaced sha1> (<replaced type>) → <replacement sha1>
105           (<replacement type>)
106

CREATING REPLACEMENT OBJECTS

108       git-hash-object(1), git-rebase(1), and git-filter-repo[1], among other
109       git commands, can be used to create replacement objects from existing
110       objects. The --edit option can also be used with git replace to create
111       a replacement object by editing an existing object.
112
113       If you want to replace many blobs, trees or commits that are part of a
114       string of commits, you may just want to create a replacement string of
115       commits and then only replace the commit at the tip of the target
116       string of commits with the commit at the tip of the replacement string
117       of commits.
118

BUGS

120       Comparing blobs or trees that have been replaced with those that
121       replace them will not work properly. And using git reset --hard to go
122       back to a replaced commit will move the branch to the replacement
123       commit instead of the replaced commit.
124
125       There may be other problems when using git rev-list related to pending
126       objects.
127

SEE ALSO

129       git-hash-object(1) git-rebase(1) git-tag(1) git-branch(1) git-commit(1)
130       git-var(1) git(1) git-filter-repo[1]
131

GIT

133       Part of the git(1) suite
134

NOTES

136        1. git-filter-repo
137           https://github.com/newren/git-filter-repo
138
139
140
141Git 2.30.2                        2021-03-08                    GIT-REPLACE(1)
Impressum