git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Bash <bash@genarts.com>
To: Johannes Sixt <j6t@kdbg.org>
Cc: git@vger.kernel.org, "Mikhail T." <mi+thun@aldan.algebra.com>
Subject: Re: How to fork a file (git cp ?)
Date: Wed, 4 May 2011 15:05:45 -0400 (EDT)	[thread overview]
Message-ID: <14525153.18843.1304535945960.JavaMail.root@mail.hq.genarts.com> (raw)
In-Reply-To: <4DC19955.7040503@kdbg.org>

----- Original Message -----
> From: "Johannes Sixt" <j6t@kdbg.org>
> Sent: Wednesday, May 4, 2011 2:22:13 PM
> Subject: Re: How to fork a file (git cp ?)
> 
> Am 04.05.2011 19:56, schrieb Mikhail T.:
> > I need to add a new thing to our project. The thing will be similar
> > to
> > what already exists. I'd like to "derive" the new files from the
> > existing ones -- without altering them and by preserving the
> > change-history.
> 
> You cannot. Git does not have such a thing as
> "copy-with-preserved-history".
> 
> You just cp the file and git add it. But you will not be able to
> follow a history of the file.

Log (and other commands) can search for copies while traversing history:

  -C[<n>]
  --find-copies[=<n>]
  Detect copies as well as renames. See also --find-copies-harder. If n is specified, it has the same meaning as for -M<n>.

  --find-copies-harder
  For performance reasons, by default, -C option finds copies only if the original file of the copy was modified in the same changeset. This flag makes the command inspect unmodified files as candidates for the source of copy. This is a very expensive operation for large projects, so use it with caution. Giving more than one -C option has the same effect.

But as I discovered a few weeks ago, the existing merge strategies don't understand copies (recursive can follow a rename, but if two files pass rename detection, I think the one with the higher similarity index wins).

Thanks,
Stephen

  reply	other threads:[~2011-05-04 19:13 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-04 17:56 How to fork a file (git cp ?) Mikhail T.
2011-05-04 18:16 ` Johannes Sixt
2011-05-04 18:22 ` Johannes Sixt
2011-05-04 19:05   ` Stephen Bash [this message]
2011-05-04 19:17   ` Mikhail T.
2011-05-04 20:36     ` Øyvind A. Holm
2011-05-04 21:02   ` Junio C Hamano
2011-05-05  1:58     ` Mikhail T.
2011-05-05  2:14       ` Junio C Hamano
2011-05-05 18:02         ` Piotr Krukowiecki
2011-05-05 18:50           ` Junio C Hamano
2011-05-05 19:27             ` Piotr Krukowiecki
2011-05-05 19:31         ` Mikhail T.
2011-05-05 20:01           ` Jeff King
2011-05-05 20:01           ` Piotr Krukowiecki
2011-05-05 20:06             ` Piotr Krukowiecki
2011-05-05 20:07             ` Jeff King
2011-05-08 19:40             ` Pete Harlan
2011-05-08 20:03               ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=14525153.18843.1304535945960.JavaMail.root@mail.hq.genarts.com \
    --to=bash@genarts.com \
    --cc=git@vger.kernel.org \
    --cc=j6t@kdbg.org \
    --cc=mi+thun@aldan.algebra.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).