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