]>
Commit | Line | Data |
---|---|---|
0f3a5bfd CC |
1 | git-replace(1) |
2 | ============== | |
3 | ||
4 | NAME | |
5 | ---- | |
6 | git-replace - Create, list, delete refs to replace objects | |
7 | ||
8 | SYNOPSIS | |
9 | -------- | |
10 | [verse] | |
11 | 'git replace' [-f] <object> <replacement> | |
4e4b125c | 12 | 'git replace' [-f] --edit <object> |
78024c4e | 13 | 'git replace' [-f] --graft <commit> [<parent>...] |
0f3a5bfd | 14 | 'git replace' -d <object>... |
34a33222 | 15 | 'git replace' [--format=<format>] [-l [<pattern>]] |
0f3a5bfd CC |
16 | |
17 | DESCRIPTION | |
18 | ----------- | |
831e61f8 | 19 | Adds a 'replace' reference in `refs/replace/` namespace. |
0f3a5bfd | 20 | |
d5fa1f1a TA |
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 | |
0f3a5bfd CC |
23 | replacement object. |
24 | ||
160df71e CC |
25 | The replaced object and the replacement object must be of the same type. |
26 | This restriction can be bypassed using `-f`. | |
27 | ||
831e61f8 | 28 | Unless `-f` is given, the 'replace' reference must not yet exist. |
0f3a5bfd | 29 | |
160df71e | 30 | There is no other restriction on the replaced and replacement objects. |
90749253 | 31 | Merge commits can be replaced by non-merge commits and vice versa. |
160df71e | 32 | |
2de9b711 | 33 | Replacement references will be used by default by all Git commands |
ddae8ae8 CC |
34 | except those doing reachability traversal (prune, pack transfer and |
35 | fsck). | |
b0fa7ab5 | 36 | |
ddae8ae8 CC |
37 | It is possible to disable use of replacement references for any |
38 | command using the `--no-replace-objects` option just after 'git'. | |
b0fa7ab5 | 39 | |
ddae8ae8 | 40 | For example if commit 'foo' has been replaced by commit 'bar': |
b0fa7ab5 CC |
41 | |
42 | ------------------------------------------------ | |
ddae8ae8 | 43 | $ git --no-replace-objects cat-file commit foo |
b0fa7ab5 CC |
44 | ------------------------------------------------ |
45 | ||
ddae8ae8 | 46 | shows information about commit 'foo', while: |
b0fa7ab5 CC |
47 | |
48 | ------------------------------------------------ | |
49 | $ git cat-file commit foo | |
50 | ------------------------------------------------ | |
51 | ||
ddae8ae8 | 52 | shows information about commit 'bar'. |
b0fa7ab5 | 53 | |
0de8b947 CC |
54 | The 'GIT_NO_REPLACE_OBJECTS' environment variable can be set to |
55 | achieve the same effect as the `--no-replace-objects` option. | |
56 | ||
0f3a5bfd CC |
57 | OPTIONS |
58 | ------- | |
59 | -f:: | |
ed0ff809 | 60 | --force:: |
0f3a5bfd CC |
61 | If an existing replace ref for the same object exists, it will |
62 | be overwritten (instead of failing). | |
63 | ||
64 | -d:: | |
ed0ff809 | 65 | --delete:: |
0f3a5bfd CC |
66 | Delete existing replace refs for the given objects. |
67 | ||
4e4b125c CC |
68 | --edit <object>:: |
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. | |
76 | ||
2deda629 JK |
77 | --raw:: |
78 | When editing, provide the raw object contents rather than | |
79 | pretty-printed ones. Currently this only affects trees, which | |
80 | will be shown in their binary form. This is harder to work with, | |
81 | but can help when repairing a tree that is so corrupted it | |
82 | cannot be pretty-printed. Note that you may need to configure | |
83 | your editor to cleanly read and write binary data. | |
84 | ||
78024c4e CC |
85 | --graft <commit> [<parent>...]:: |
86 | Create a graft commit. A new commit is created with the same | |
87 | content as <commit> except that its parents will be | |
88 | [<parent>...] instead of <commit>'s parents. A replacement ref | |
89 | is then created to replace <commit> with the newly created | |
b0ab2b71 CC |
90 | commit. See contrib/convert-grafts-to-replace-refs.sh for an |
91 | example script based on this option that can convert grafts to | |
92 | replace refs. | |
78024c4e | 93 | |
0f3a5bfd | 94 | -l <pattern>:: |
ed0ff809 | 95 | --list <pattern>:: |
0f3a5bfd CC |
96 | List replace refs for objects that match the given pattern (or |
97 | all if no pattern is given). | |
98 | Typing "git replace" without arguments, also lists all replace | |
99 | refs. | |
100 | ||
34a33222 CC |
101 | --format=<format>:: |
102 | When listing, use the specified <format>, which can be one of | |
663a8566 | 103 | 'short', 'medium' and 'long'. When omitted, the format |
34a33222 CC |
104 | defaults to 'short'. |
105 | ||
106 | FORMATS | |
107 | ------- | |
108 | ||
109 | The following format are available: | |
110 | ||
111 | * 'short': | |
112 | <replaced sha1> | |
113 | * 'medium': | |
114 | <replaced sha1> -> <replacement sha1> | |
663a8566 | 115 | * 'long': |
34a33222 CC |
116 | <replaced sha1> (<replaced type>) -> <replacement sha1> (<replacement type>) |
117 | ||
b8fcce1e CC |
118 | CREATING REPLACEMENT OBJECTS |
119 | ---------------------------- | |
120 | ||
121 | linkgit:git-filter-branch[1], linkgit:git-hash-object[1] and | |
122 | linkgit:git-rebase[1], among other git commands, can be used to create | |
4e4b125c CC |
123 | replacement objects from existing objects. The `--edit` option can |
124 | also be used with 'git replace' to create a replacement object by | |
125 | editing an existing object. | |
b8fcce1e CC |
126 | |
127 | If you want to replace many blobs, trees or commits that are part of a | |
128 | string of commits, you may just want to create a replacement string of | |
129 | commits and then only replace the commit at the tip of the target | |
130 | string of commits with the commit at the tip of the replacement string | |
131 | of commits. | |
132 | ||
0f3a5bfd CC |
133 | BUGS |
134 | ---- | |
135 | Comparing blobs or trees that have been replaced with those that | |
ca768288 | 136 | replace them will not work properly. And using `git reset --hard` to |
0f3a5bfd CC |
137 | go back to a replaced commit will move the branch to the replacement |
138 | commit instead of the replaced commit. | |
139 | ||
140 | There may be other problems when using 'git rev-list' related to | |
160df71e | 141 | pending objects. |
0f3a5bfd CC |
142 | |
143 | SEE ALSO | |
144 | -------- | |
b8fcce1e CC |
145 | linkgit:git-hash-object[1] |
146 | linkgit:git-filter-branch[1] | |
147 | linkgit:git-rebase[1] | |
0f3a5bfd CC |
148 | linkgit:git-tag[1] |
149 | linkgit:git-branch[1] | |
4e4b125c CC |
150 | linkgit:git-commit[1] |
151 | linkgit:git-var[1] | |
b0fa7ab5 | 152 | linkgit:git[1] |
0f3a5bfd | 153 | |
0f3a5bfd CC |
154 | GIT |
155 | --- | |
156 | Part of the linkgit:git[1] suite |