]> git.ipfire.org Git - thirdparty/git.git/blame - Documentation/git-replace.txt
Documentation/replace: add Creating Replacement Objects section
[thirdparty/git.git] / Documentation / git-replace.txt
CommitLineData
0f3a5bfd
CC
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' -l [<pattern>]
14
15DESCRIPTION
16-----------
831e61f8 17Adds a 'replace' reference in `refs/replace/` namespace.
0f3a5bfd 18
d5fa1f1a
TA
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
0f3a5bfd
CC
21replacement object.
22
160df71e
CC
23The replaced object and the replacement object must be of the same type.
24This restriction can be bypassed using `-f`.
25
831e61f8 26Unless `-f` is given, the 'replace' reference must not yet exist.
0f3a5bfd 27
160df71e
CC
28There is no other restriction on the replaced and replacement objects.
29
2de9b711 30Replacement references will be used by default by all Git commands
ddae8ae8
CC
31except those doing reachability traversal (prune, pack transfer and
32fsck).
b0fa7ab5 33
ddae8ae8
CC
34It is possible to disable use of replacement references for any
35command using the `--no-replace-objects` option just after 'git'.
b0fa7ab5 36
ddae8ae8 37For example if commit 'foo' has been replaced by commit 'bar':
b0fa7ab5
CC
38
39------------------------------------------------
ddae8ae8 40$ git --no-replace-objects cat-file commit foo
b0fa7ab5
CC
41------------------------------------------------
42
ddae8ae8 43shows information about commit 'foo', while:
b0fa7ab5
CC
44
45------------------------------------------------
46$ git cat-file commit foo
47------------------------------------------------
48
ddae8ae8 49shows information about commit 'bar'.
b0fa7ab5 50
0de8b947
CC
51The 'GIT_NO_REPLACE_OBJECTS' environment variable can be set to
52achieve the same effect as the `--no-replace-objects` option.
53
0f3a5bfd
CC
54OPTIONS
55-------
56-f::
57 If an existing replace ref for the same object exists, it will
58 be overwritten (instead of failing).
59
60-d::
61 Delete existing replace refs for the given objects.
62
63-l <pattern>::
64 List replace refs for objects that match the given pattern (or
65 all if no pattern is given).
66 Typing "git replace" without arguments, also lists all replace
67 refs.
68
b8fcce1e
CC
69CREATING REPLACEMENT OBJECTS
70----------------------------
71
72linkgit:git-filter-branch[1], linkgit:git-hash-object[1] and
73linkgit:git-rebase[1], among other git commands, can be used to create
74replacement objects from existing objects.
75
76If you want to replace many blobs, trees or commits that are part of a
77string of commits, you may just want to create a replacement string of
78commits and then only replace the commit at the tip of the target
79string of commits with the commit at the tip of the replacement string
80of commits.
81
0f3a5bfd
CC
82BUGS
83----
84Comparing blobs or trees that have been replaced with those that
ca768288 85replace them will not work properly. And using `git reset --hard` to
0f3a5bfd
CC
86go back to a replaced commit will move the branch to the replacement
87commit instead of the replaced commit.
88
89There may be other problems when using 'git rev-list' related to
160df71e 90pending objects.
0f3a5bfd
CC
91
92SEE ALSO
93--------
b8fcce1e
CC
94linkgit:git-hash-object[1]
95linkgit:git-filter-branch[1]
96linkgit:git-rebase[1]
0f3a5bfd
CC
97linkgit:git-tag[1]
98linkgit:git-branch[1]
b0fa7ab5 99linkgit:git[1]
0f3a5bfd 100
0f3a5bfd
CC
101GIT
102---
103Part of the linkgit:git[1] suite