]> git.ipfire.org Git - thirdparty/git.git/blame_incremental - Documentation/git-replace.txt
replace: add --edit to usage string
[thirdparty/git.git] / Documentation / git-replace.txt
... / ...
CommitLineData
1git-replace(1)
2==============
3
4NAME
5----
6git-replace - Create, list, delete refs to replace objects
7
8SYNOPSIS
9--------
10[verse]
11'git replace' [-f] <object> <replacement>
12'git replace' -d <object>...
13'git replace' [--format=<format>] [-l [<pattern>]]
14
15DESCRIPTION
16-----------
17Adds a 'replace' reference in `refs/replace/` namespace.
18
19The name of the 'replace' reference is the SHA-1 of the object that is
20replaced. The content of the 'replace' reference is the SHA-1 of the
21replacement object.
22
23The replaced object and the replacement object must be of the same type.
24This restriction can be bypassed using `-f`.
25
26Unless `-f` is given, the 'replace' reference must not yet exist.
27
28There is no other restriction on the replaced and replacement objects.
29Merge commits can be replaced by non-merge commits and vice versa.
30
31Replacement references will be used by default by all Git commands
32except those doing reachability traversal (prune, pack transfer and
33fsck).
34
35It is possible to disable use of replacement references for any
36command using the `--no-replace-objects` option just after 'git'.
37
38For example if commit 'foo' has been replaced by commit 'bar':
39
40------------------------------------------------
41$ git --no-replace-objects cat-file commit foo
42------------------------------------------------
43
44shows information about commit 'foo', while:
45
46------------------------------------------------
47$ git cat-file commit foo
48------------------------------------------------
49
50shows information about commit 'bar'.
51
52The 'GIT_NO_REPLACE_OBJECTS' environment variable can be set to
53achieve the same effect as the `--no-replace-objects` option.
54
55OPTIONS
56-------
57-f::
58--force::
59 If an existing replace ref for the same object exists, it will
60 be overwritten (instead of failing).
61
62-d::
63--delete::
64 Delete existing replace refs for the given objects.
65
66-l <pattern>::
67--list <pattern>::
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
71 refs.
72
73--format=<format>::
74 When listing, use the specified <format>, which can be one of
75 'short', 'medium' and 'long'. When omitted, the format
76 defaults to 'short'.
77
78FORMATS
79-------
80
81The following format are available:
82
83* 'short':
84 <replaced sha1>
85* 'medium':
86 <replaced sha1> -> <replacement sha1>
87* 'long':
88 <replaced sha1> (<replaced type>) -> <replacement sha1> (<replacement type>)
89
90CREATING REPLACEMENT OBJECTS
91----------------------------
92
93linkgit:git-filter-branch[1], linkgit:git-hash-object[1] and
94linkgit:git-rebase[1], among other git commands, can be used to create
95replacement objects from existing objects.
96
97If you want to replace many blobs, trees or commits that are part of a
98string of commits, you may just want to create a replacement string of
99commits and then only replace the commit at the tip of the target
100string of commits with the commit at the tip of the replacement string
101of commits.
102
103BUGS
104----
105Comparing blobs or trees that have been replaced with those that
106replace them will not work properly. And using `git reset --hard` to
107go back to a replaced commit will move the branch to the replacement
108commit instead of the replaced commit.
109
110There may be other problems when using 'git rev-list' related to
111pending objects.
112
113SEE ALSO
114--------
115linkgit:git-hash-object[1]
116linkgit:git-filter-branch[1]
117linkgit:git-rebase[1]
118linkgit:git-tag[1]
119linkgit:git-branch[1]
120linkgit:git[1]
121
122GIT
123---
124Part of the linkgit:git[1] suite