logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

git-replace.1 (7029B)


  1. '\" t
  2. .\" Title: git-replace
  3. .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author]
  4. .\" Generator: DocBook XSL Stylesheets v1.79.2 <http://docbook.sf.net/>
  5. .\" Date: 2025-03-14
  6. .\" Manual: Git Manual
  7. .\" Source: Git 2.49.0
  8. .\" Language: English
  9. .\"
  10. .TH "GIT\-REPLACE" "1" "2025-03-14" "Git 2\&.49\&.0" "Git Manual"
  11. .\" -----------------------------------------------------------------
  12. .\" * Define some portability stuff
  13. .\" -----------------------------------------------------------------
  14. .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  15. .\" http://bugs.debian.org/507673
  16. .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
  17. .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  18. .ie \n(.g .ds Aq \(aq
  19. .el .ds Aq '
  20. .\" -----------------------------------------------------------------
  21. .\" * set default formatting
  22. .\" -----------------------------------------------------------------
  23. .\" disable hyphenation
  24. .nh
  25. .\" disable justification (adjust text to left margin only)
  26. .ad l
  27. .\" -----------------------------------------------------------------
  28. .\" * MAIN CONTENT STARTS HERE *
  29. .\" -----------------------------------------------------------------
  30. .SH "NAME"
  31. git-replace \- Create, list, delete refs to replace objects
  32. .SH "SYNOPSIS"
  33. .sp
  34. .nf
  35. \fIgit replace\fR [\-f] <object> <replacement>
  36. \fIgit replace\fR [\-f] \-\-edit <object>
  37. \fIgit replace\fR [\-f] \-\-graft <commit> [<parent>\&...\:]
  38. \fIgit replace\fR [\-f] \-\-convert\-graft\-file
  39. \fIgit replace\fR \-d <object>\&...\:
  40. \fIgit replace\fR [\-\-format=<format>] [\-l [<pattern>]]
  41. .fi
  42. .SH "DESCRIPTION"
  43. .sp
  44. Adds a \fIreplace\fR reference in \fBrefs/replace/\fR namespace\&.
  45. .sp
  46. The name of the \fIreplace\fR reference is the SHA\-1 of the object that is replaced\&. The content of the \fIreplace\fR reference is the SHA\-1 of the replacement object\&.
  47. .sp
  48. The replaced object and the replacement object must be of the same type\&. This restriction can be bypassed using \fB\-f\fR\&.
  49. .sp
  50. Unless \fB\-f\fR is given, the \fIreplace\fR reference must not yet exist\&.
  51. .sp
  52. There is no other restriction on the replaced and replacement objects\&. Merge commits can be replaced by non\-merge commits and vice versa\&.
  53. .sp
  54. Replacement references will be used by default by all Git commands except those doing reachability traversal (prune, pack transfer and fsck)\&.
  55. .sp
  56. It is possible to disable the use of replacement references for any command using the \fB\-\-no\-replace\-objects\fR option just after \fIgit\fR\&.
  57. .sp
  58. For example if commit \fIfoo\fR has been replaced by commit \fIbar\fR:
  59. .sp
  60. .if n \{\
  61. .RS 4
  62. .\}
  63. .nf
  64. $ git \-\-no\-replace\-objects cat\-file commit foo
  65. .fi
  66. .if n \{\
  67. .RE
  68. .\}
  69. .sp
  70. shows information about commit \fIfoo\fR, while:
  71. .sp
  72. .if n \{\
  73. .RS 4
  74. .\}
  75. .nf
  76. $ git cat\-file commit foo
  77. .fi
  78. .if n \{\
  79. .RE
  80. .\}
  81. .sp
  82. shows information about commit \fIbar\fR\&.
  83. .sp
  84. The \fBGIT_NO_REPLACE_OBJECTS\fR environment variable can be set to achieve the same effect as the \fB\-\-no\-replace\-objects\fR option\&.
  85. .SH "OPTIONS"
  86. .PP
  87. \-f, \-\-force
  88. .RS 4
  89. If an existing replace ref for the same object exists, it will be overwritten (instead of failing)\&.
  90. .RE
  91. .PP
  92. \-d, \-\-delete
  93. .RS 4
  94. Delete existing replace refs for the given objects\&.
  95. .RE
  96. .PP
  97. \-\-edit <object>
  98. .RS 4
  99. Edit an object\(cqs content interactively\&. The existing content for <object> is pretty\-printed into a temporary file, an editor is launched on the file, and the result is parsed to create a new object of the same type as <object>\&. A replacement ref is then created to replace <object> with the newly created object\&. See
  100. \fBgit-var\fR(1)
  101. for details about how the editor will be chosen\&.
  102. .RE
  103. .PP
  104. \-\-raw
  105. .RS 4
  106. When editing, provide the raw object contents rather than pretty\-printed ones\&. Currently this only affects trees, which will be shown in their binary form\&. This is harder to work with, but can help when repairing a tree that is so corrupted it cannot be pretty\-printed\&. Note that you may need to configure your editor to cleanly read and write binary data\&.
  107. .RE
  108. .PP
  109. \-\-graft <commit> [<parent>\&...\:]
  110. .RS 4
  111. Create a graft commit\&. A new commit is created with the same content as <commit> except that its parents will be [<parent>\&...\:] instead of <commit>\*(Aqs parents\&. A replacement ref is then created to replace <commit> with the newly created commit\&. Use
  112. \fB\-\-convert\-graft\-file\fR
  113. to convert a
  114. \fB$GIT_DIR/info/grafts\fR
  115. file and use replace refs instead\&.
  116. .RE
  117. .PP
  118. \-\-convert\-graft\-file
  119. .RS 4
  120. Creates graft commits for all entries in
  121. \fB$GIT_DIR/info/grafts\fR
  122. and deletes that file upon success\&. The purpose is to help users with transitioning off of the now\-deprecated graft file\&.
  123. .RE
  124. .PP
  125. \-l <pattern>, \-\-list <pattern>
  126. .RS 4
  127. List replace refs for objects that match the given pattern (or all if no pattern is given)\&. Typing "git replace" without arguments, also lists all replace refs\&.
  128. .RE
  129. .PP
  130. \-\-format=<format>
  131. .RS 4
  132. When listing, use the specified <format>, which can be one of
  133. \fIshort\fR,
  134. \fImedium\fR
  135. and
  136. \fIlong\fR\&. When omitted, the format defaults to
  137. \fIshort\fR\&.
  138. .RE
  139. .SH "FORMATS"
  140. .sp
  141. The following formats are available:
  142. .sp
  143. .RS 4
  144. .ie n \{\
  145. \h'-04'\(bu\h'+03'\c
  146. .\}
  147. .el \{\
  148. .sp -1
  149. .IP \(bu 2.3
  150. .\}
  151. \fIshort\fR: <replaced\-sha1>
  152. .RE
  153. .sp
  154. .RS 4
  155. .ie n \{\
  156. \h'-04'\(bu\h'+03'\c
  157. .\}
  158. .el \{\
  159. .sp -1
  160. .IP \(bu 2.3
  161. .\}
  162. \fImedium\fR: <replaced\-sha1> \(-> <replacement\-sha1>
  163. .RE
  164. .sp
  165. .RS 4
  166. .ie n \{\
  167. \h'-04'\(bu\h'+03'\c
  168. .\}
  169. .el \{\
  170. .sp -1
  171. .IP \(bu 2.3
  172. .\}
  173. \fIlong\fR: <replaced\-sha1> (<replaced\-type>) \(-> <replacement\-sha1> (<replacement\-type>)
  174. .RE
  175. .SH "CREATING REPLACEMENT OBJECTS"
  176. .sp
  177. \fBgit-hash-object\fR(1), \fBgit-rebase\fR(1), and \m[blue]\fBgit\-filter\-repo\fR\m[]\&\s-2\u[1]\d\s+2, among other git commands, can be used to create replacement objects from existing objects\&. The \fB\-\-edit\fR option can also be used with \fIgit replace\fR to create a replacement object by editing an existing object\&.
  178. .sp
  179. If you want to replace many blobs, trees or commits that are part of a string of commits, you may just want to create a replacement string of commits and then only replace the commit at the tip of the target string of commits with the commit at the tip of the replacement string of commits\&.
  180. .SH "BUGS"
  181. .sp
  182. Comparing blobs or trees that have been replaced with those that replace them will not work properly\&. And using \fBgit\fR \fBreset\fR \fB\-\-hard\fR to go back to a replaced commit will move the branch to the replacement commit instead of the replaced commit\&.
  183. .sp
  184. There may be other problems when using \fIgit rev\-list\fR related to pending objects\&.
  185. .SH "SEE ALSO"
  186. .sp
  187. \fBgit-hash-object\fR(1) \fBgit-rebase\fR(1) \fBgit-tag\fR(1) \fBgit-branch\fR(1) \fBgit-commit\fR(1) \fBgit-var\fR(1) \fBgit\fR(1) \m[blue]\fBgit\-filter\-repo\fR\m[]\&\s-2\u[1]\d\s+2
  188. .SH "GIT"
  189. .sp
  190. Part of the \fBgit\fR(1) suite
  191. .SH "NOTES"
  192. .IP " 1." 4
  193. git-filter-repo
  194. .RS 4
  195. \%https://github.com/newren/git-filter-repo
  196. .RE