]>
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> |
0f3a5bfd | 13 | 'git replace' -d <object>... |
34a33222 | 14 | 'git replace' [--format=<format>] [-l [<pattern>]] |
0f3a5bfd CC |
15 | |
16 | DESCRIPTION | |
17 | ----------- | |
831e61f8 | 18 | Adds a 'replace' reference in `refs/replace/` namespace. |
0f3a5bfd | 19 | |
d5fa1f1a TA |
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 | |
0f3a5bfd CC |
22 | replacement object. |
23 | ||
160df71e CC |
24 | The replaced object and the replacement object must be of the same type. |
25 | This restriction can be bypassed using `-f`. | |
26 | ||
831e61f8 | 27 | Unless `-f` is given, the 'replace' reference must not yet exist. |
0f3a5bfd | 28 | |
160df71e | 29 | There is no other restriction on the replaced and replacement objects. |
90749253 | 30 | Merge commits can be replaced by non-merge commits and vice versa. |
160df71e | 31 | |
2de9b711 | 32 | Replacement references will be used by default by all Git commands |
ddae8ae8 CC |
33 | except those doing reachability traversal (prune, pack transfer and |
34 | fsck). | |
b0fa7ab5 | 35 | |
ddae8ae8 CC |
36 | It is possible to disable use of replacement references for any |
37 | command using the `--no-replace-objects` option just after 'git'. | |
b0fa7ab5 | 38 | |
ddae8ae8 | 39 | For example if commit 'foo' has been replaced by commit 'bar': |
b0fa7ab5 CC |
40 | |
41 | ------------------------------------------------ | |
ddae8ae8 | 42 | $ git --no-replace-objects cat-file commit foo |
b0fa7ab5 CC |
43 | ------------------------------------------------ |
44 | ||
ddae8ae8 | 45 | shows information about commit 'foo', while: |
b0fa7ab5 CC |
46 | |
47 | ------------------------------------------------ | |
48 | $ git cat-file commit foo | |
49 | ------------------------------------------------ | |
50 | ||
ddae8ae8 | 51 | shows information about commit 'bar'. |
b0fa7ab5 | 52 | |
0de8b947 CC |
53 | The 'GIT_NO_REPLACE_OBJECTS' environment variable can be set to |
54 | achieve the same effect as the `--no-replace-objects` option. | |
55 | ||
0f3a5bfd CC |
56 | OPTIONS |
57 | ------- | |
58 | -f:: | |
ed0ff809 | 59 | --force:: |
0f3a5bfd CC |
60 | If an existing replace ref for the same object exists, it will |
61 | be overwritten (instead of failing). | |
62 | ||
63 | -d:: | |
ed0ff809 | 64 | --delete:: |
0f3a5bfd CC |
65 | Delete existing replace refs for the given objects. |
66 | ||
4e4b125c CC |
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. | |
75 | ||
0f3a5bfd | 76 | -l <pattern>:: |
ed0ff809 | 77 | --list <pattern>:: |
0f3a5bfd CC |
78 | List replace refs for objects that match the given pattern (or |
79 | all if no pattern is given). | |
80 | Typing "git replace" without arguments, also lists all replace | |
81 | refs. | |
82 | ||
34a33222 CC |
83 | --format=<format>:: |
84 | When listing, use the specified <format>, which can be one of | |
663a8566 | 85 | 'short', 'medium' and 'long'. When omitted, the format |
34a33222 CC |
86 | defaults to 'short'. |
87 | ||
88 | FORMATS | |
89 | ------- | |
90 | ||
91 | The following format are available: | |
92 | ||
93 | * 'short': | |
94 | <replaced sha1> | |
95 | * 'medium': | |
96 | <replaced sha1> -> <replacement sha1> | |
663a8566 | 97 | * 'long': |
34a33222 CC |
98 | <replaced sha1> (<replaced type>) -> <replacement sha1> (<replacement type>) |
99 | ||
b8fcce1e CC |
100 | CREATING REPLACEMENT OBJECTS |
101 | ---------------------------- | |
102 | ||
103 | linkgit:git-filter-branch[1], linkgit:git-hash-object[1] and | |
104 | linkgit:git-rebase[1], among other git commands, can be used to create | |
4e4b125c CC |
105 | replacement objects from existing objects. The `--edit` option can |
106 | also be used with 'git replace' to create a replacement object by | |
107 | editing an existing object. | |
b8fcce1e CC |
108 | |
109 | If you want to replace many blobs, trees or commits that are part of a | |
110 | string of commits, you may just want to create a replacement string of | |
111 | commits and then only replace the commit at the tip of the target | |
112 | string of commits with the commit at the tip of the replacement string | |
113 | of commits. | |
114 | ||
0f3a5bfd CC |
115 | BUGS |
116 | ---- | |
117 | Comparing blobs or trees that have been replaced with those that | |
ca768288 | 118 | replace them will not work properly. And using `git reset --hard` to |
0f3a5bfd CC |
119 | go back to a replaced commit will move the branch to the replacement |
120 | commit instead of the replaced commit. | |
121 | ||
122 | There may be other problems when using 'git rev-list' related to | |
160df71e | 123 | pending objects. |
0f3a5bfd CC |
124 | |
125 | SEE ALSO | |
126 | -------- | |
b8fcce1e CC |
127 | linkgit:git-hash-object[1] |
128 | linkgit:git-filter-branch[1] | |
129 | linkgit:git-rebase[1] | |
0f3a5bfd CC |
130 | linkgit:git-tag[1] |
131 | linkgit:git-branch[1] | |
4e4b125c CC |
132 | linkgit:git-commit[1] |
133 | linkgit:git-var[1] | |
b0fa7ab5 | 134 | linkgit:git[1] |
0f3a5bfd | 135 | |
0f3a5bfd CC |
136 | GIT |
137 | --- | |
138 | Part of the linkgit:git[1] suite |