Re: How to fork a file (git cp ?)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Johannes Sixt <j6t@xxxxxxxx> writes:

> 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".

Well, if you come from the mindset that a "file" has an identity (hence
there is a distinction between "This file used to be called A and at one
point was renamed to B which is the name we see today" and "Some time ago
somebody created a file B with the same contents as A and then removed A
at the same time"), "copy" would not make much sense.  What identity does
a new file B gets when you create it by copying from A?

The same identity, or a different one?  What happens when you later
refactor the redundant part from these two files to create a common third
file C?  What identity does C have?

> You just cp the file and git add it. But you will not be able to follow
> a history of the file.

Correct.  You cannot follow a history of _the file_, as there is no such
thing.

You can still follow the history of contents, though.  If you did a
refactor like the one in the above example, "blame -L <range>" would
follow the contents just fine.  The command is a 80% satisfactory
implementation of Linus's grand vision expressed in one of the most
important message in the git mailing list archive:

    http://thread.gmane.org/gmane.comp.version-control.git/27/focus=217

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]