git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Øyvind A. Holm" <sunny@sunbase.org>
To: "Mikhail T." <mi+thun@aldan.algebra.com>
Cc: Johannes Sixt <j6t@kdbg.org>, git@vger.kernel.org
Subject: Re: How to fork a file (git cp ?)
Date: Wed, 4 May 2011 22:36:39 +0200	[thread overview]
Message-ID: <BANLkTinEb5BmR_Ls8YtGxyqGSVVBcnG32A@mail.gmail.com> (raw)
In-Reply-To: <4DC1A64C.4090508@aldan.algebra.com>

On 4 May 2011 21:17, Mikhail T. <mi+thun@aldan.algebra.com> wrote:
> On 04.05.2011 14:22, Johannes Sixt wrote:
> >
> > You just cp the file and git add it. But you will not be able to
> > follow a history of the file.
>
> Thank you for the information...
>
> So, is this something worth adding to the wishlist, or was it omitted
> on purpose (and which purpose was that, then)?

Oh yes, that was intentional. This is easily one of the most debated
"features" of Git, especially in the early days of Git when almost all
SCM systems did it "the CVS way", by tracking the history of single
files. Instead, Git tracks snapshots of the whole tree and focuses on
the whole content instead of single files. Renames are tracked by
detecting removal/adding of files, which can be detected later, for
example using "git log --follow". The reason for this is mostly speed
issues, and most of the time the history of a single file is not
interesting in a project, but changes in the file tree as a whole.

From the FAQ at <https://git.wiki.kernel.org/index.php/GitFaq>:

  Git has to interoperate with a lot of different workflows, for example
  some changes can come from patches, where rename information may not
  be available. Relying on explicit rename tracking makes it impossible
  to merge two trees that have done exactly the same thing, except one
  did it as a patch (create/delete) and one did it using some other
  heuristic.

  On a second note, tracking renames is really just a special case of
  tracking how content moves in the tree. In some cases, you may instead
  be interested in querying when a function was added or moved to a
  different file. By only relying on the ability to recreate this
  information when needed, Git aims to provide a more flexible way to
  track how your tree is changing.

  However, this does not mean that Git has no support for renames. The
  diff machinery in Git has support for automatically detecting renames,
  this is turned on by the '-M' switch to the git-diff-* family of
  commands. The rename detection machinery is used by git-log(1) and
  git-whatchanged(1), so for example, 'git log -M' will give the commit
  history with rename information. Git also supports a limited form of
  merging across renames. The two tools for assigning blame,
  git-blame(1) and git-annotate(1) both use the automatic rename
  detection code to track renames.

  As a very special case, 'git log' version 1.5.3 and later has
  '--follow' option that allows you to follow renames when given a
  single path.

  Git has a rename command git mv, but that is just for convenience. The
  effect is indistinguishable from removing the file and adding another
  with different name and the same content.

This mail from Linus explains the issue in more detail and colour:
<http://permalink.gmane.org/gmane.comp.version-control.git/217>.

Regards,
Øyvind

  reply	other threads:[~2011-05-04 20:36 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
2011-05-04 19:17   ` Mikhail T.
2011-05-04 20:36     ` Øyvind A. Holm [this message]
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=BANLkTinEb5BmR_Ls8YtGxyqGSVVBcnG32A@mail.gmail.com \
    --to=sunny@sunbase.org \
    --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).