Merge branch 'kb/perf-trace'
[git.git] / Documentation / git-replace.txt
blob089dcac0478407a89aea702988adcb4135510180
1 git-replace(1)
2 ==============
4 NAME
5 ----
6 git-replace - Create, list, delete refs to replace objects
8 SYNOPSIS
9 --------
10 [verse]
11 'git replace' [-f] <object> <replacement>
12 'git replace' [-f] --edit <object>
13 'git replace' -d <object>...
14 'git replace' [--format=<format>] [-l [<pattern>]]
16 DESCRIPTION
17 -----------
18 Adds a 'replace' reference in `refs/replace/` namespace.
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.
24 The replaced object and the replacement object must be of the same type.
25 This restriction can be bypassed using `-f`.
27 Unless `-f` is given, the 'replace' reference must not yet exist.
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.
32 Replacement references will be used by default by all Git commands
33 except those doing reachability traversal (prune, pack transfer and
34 fsck).
36 It is possible to disable use of replacement references for any
37 command using the `--no-replace-objects` option just after 'git'.
39 For example if commit 'foo' has been replaced by commit 'bar':
41 ------------------------------------------------
42 $ git --no-replace-objects cat-file commit foo
43 ------------------------------------------------
45 shows information about commit 'foo', while:
47 ------------------------------------------------
48 $ git cat-file commit foo
49 ------------------------------------------------
51 shows information about commit 'bar'.
53 The 'GIT_NO_REPLACE_OBJECTS' environment variable can be set to
54 achieve the same effect as the `--no-replace-objects` option.
56 OPTIONS
57 -------
58 -f::
59 --force::
60         If an existing replace ref for the same object exists, it will
61         be overwritten (instead of failing).
63 -d::
64 --delete::
65         Delete existing replace refs for the given objects.
67 --edit <object>::
68         Edit an object's content interactively. The existing content
69         for <object> is pretty-printed into a temporary file, an
70         editor is launched on the file, and the result is parsed to
71         create a new object of the same type as <object>. A
72         replacement ref is then created to replace <object> with the
73         newly created object. See linkgit:git-var[1] for details about
74         how the editor will be chosen.
76 --raw::
77         When editing, provide the raw object contents rather than
78         pretty-printed ones. Currently this only affects trees, which
79         will be shown in their binary form. This is harder to work with,
80         but can help when repairing a tree that is so corrupted it
81         cannot be pretty-printed. Note that you may need to configure
82         your editor to cleanly read and write binary data.
84 -l <pattern>::
85 --list <pattern>::
86         List replace refs for objects that match the given pattern (or
87         all if no pattern is given).
88         Typing "git replace" without arguments, also lists all replace
89         refs.
91 --format=<format>::
92         When listing, use the specified <format>, which can be one of
93         'short', 'medium' and 'long'. When omitted, the format
94         defaults to 'short'.
96 FORMATS
97 -------
99 The following format are available:
101 * 'short':
102         <replaced sha1>
103 * 'medium':
104         <replaced sha1> -> <replacement sha1>
105 * 'long':
106         <replaced sha1> (<replaced type>) -> <replacement sha1> (<replacement type>)
108 CREATING REPLACEMENT OBJECTS
109 ----------------------------
111 linkgit:git-filter-branch[1], linkgit:git-hash-object[1] and
112 linkgit:git-rebase[1], among other git commands, can be used to create
113 replacement objects from existing objects. The `--edit` option can
114 also be used with 'git replace' to create a replacement object by
115 editing an existing object.
117 If you want to replace many blobs, trees or commits that are part of a
118 string of commits, you may just want to create a replacement string of
119 commits and then only replace the commit at the tip of the target
120 string of commits with the commit at the tip of the replacement string
121 of commits.
123 BUGS
124 ----
125 Comparing blobs or trees that have been replaced with those that
126 replace them will not work properly. And using `git reset --hard` to
127 go back to a replaced commit will move the branch to the replacement
128 commit instead of the replaced commit.
130 There may be other problems when using 'git rev-list' related to
131 pending objects.
133 SEE ALSO
134 --------
135 linkgit:git-hash-object[1]
136 linkgit:git-filter-branch[1]
137 linkgit:git-rebase[1]
138 linkgit:git-tag[1]
139 linkgit:git-branch[1]
140 linkgit:git-commit[1]
141 linkgit:git-var[1]
142 linkgit:git[1]
146 Part of the linkgit:git[1] suite