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