# A git-mv question

5 messages from 2010-02-02 to 2010-02-02. Participants: Ron Garret, Nicolas Pitre, Junio C Hamano, Jakub Narebski.
Thread: https://gitlist.dev/t/22477

## Ron Garret, 2010-02-02 00:08

Subject: A git-mv question
Message-ID: <ron1-09EE6C.16083801022010@news.gmane.org>
URL: https://gitlist.dev/e/ron1-09EE6C.16083801022010%40news.gmane.org

```
If I do a git-mv *and* edit the file all in one commit, does that get 
recorded in a way that allows git to track the change through the 
changed file name?  In other words, if I do just a git-mv (without 
changing the file) git can track that by observing that two differently 
named objects in two different commit trees contain the same blob.  But 
if the file is edited then the blobs will be different.  Is git smart 
enough to distinguish a git-mv and edit from, say, the equivalent git-rm 
and git-add?  If so, how does it do it?

Thanks,
rg

```

## Nicolas Pitre, 2010-02-02 00:29

Subject: Re: A git-mv question
Message-ID: <alpine.LFD.2.00.1002011927490.1681@xanadu.home>
URL: https://gitlist.dev/e/alpine.LFD.2.00.1002011927490.1681%40xanadu.home
In-Reply-To: <ron1-09EE6C.16083801022010@news.gmane.org>

```
On Mon, 1 Feb 2010, Ron Garret wrote:

> If I do a git-mv *and* edit the file all in one commit, does that get 
> recorded in a way that allows git to track the change through the 
> changed file name?  In other words, if I do just a git-mv (without 
> changing the file) git can track that by observing that two differently 
> named objects in two different commit trees contain the same blob.  But 
> if the file is edited then the blobs will be different.  Is git smart 
> enough to distinguish a git-mv and edit from, say, the equivalent git-rm 
> and git-add?  If so, how does it do it?

Please see:

http://www.kernel.org/pub/software/scm/git/docs/gitdiffcore.html


Nicolas

```

## Junio C Hamano, 2010-02-02 00:46

Subject: Re: A git-mv question
Message-ID: <7vwrywmpmd.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vwrywmpmd.fsf%40alter.siamese.dyndns.org
In-Reply-To: <alpine.LFD.2.00.1002011927490.1681@xanadu.home>

```
Nicolas Pitre <nico@fluxnic.net> writes:

> Please see:
>
> http://www.kernel.org/pub/software/scm/git/docs/gitdiffcore.html

Thanks.

Probably it needs a bit of updates to help new people read it.

 * It talks about diff-* family.  They exist, but what they do can be
   triggered also by "diff" wrapper and that is the primary way the users
   know about "diff" these days.

 * Because it was written to illustrate the low-level diff-* family, it
   says "when they are run without -p option".  People who only know
   Porcelain "diff" need to read as if it said "when run with --raw".

 * It does not talk about "log -p" but the discussion applies there as
   well (log is a glorified form of diff-tree).

```

## Ron Garret, 2010-02-02 07:21

Subject: Re: A git-mv question
Message-ID: <ron1-C9CA44.23215801022010@news.gmane.org>
URL: https://gitlist.dev/e/ron1-C9CA44.23215801022010%40news.gmane.org
In-Reply-To: <alpine.LFD.2.00.1002011927490.1681@xanadu.home>

```
In article <alpine.LFD.2.00.1002011927490.1681@xanadu.home>,
 Nicolas Pitre <nico@fluxnic.net> wrote:

> On Mon, 1 Feb 2010, Ron Garret wrote:
> 
> > If I do a git-mv *and* edit the file all in one commit, does that get 
> > recorded in a way that allows git to track the change through the 
> > changed file name?  In other words, if I do just a git-mv (without 
> > changing the file) git can track that by observing that two differently 
> > named objects in two different commit trees contain the same blob.  But 
> > if the file is edited then the blobs will be different.  Is git smart 
> > enough to distinguish a git-mv and edit from, say, the equivalent git-rm 
> > and git-add?  If so, how does it do it?
> 
> Please see:
> 
> http://www.kernel.org/pub/software/scm/git/docs/gitdiffcore.html
> 

Thanks!  A little light reading :-)

rg

```

## Jakub Narebski, 2010-02-02 15:32

Subject: Re: A git-mv question
Message-ID: <m3r5p3ac2e.fsf@localhost.localdomain>
URL: https://gitlist.dev/e/m3r5p3ac2e.fsf%40localhost.localdomain
In-Reply-To: <ron1-09EE6C.16083801022010@news.gmane.org>

```
Ron Garret <ron1@flownet.com> writes:

> If I do a git-mv *and* edit the file all in one commit, does that get 
> recorded in a way that allows git to track the change through the 
> changed file name?  In other words, if I do just a git-mv (without 
> changing the file) git can track that by observing that two differently 
> named objects in two different commit trees contain the same blob.  But 
> if the file is edited then the blobs will be different.  Is git smart 
> enough to distinguish a git-mv and edit from, say, the equivalent git-rm 
> and git-add?  If so, how does it do it?

Git does not distinguish between git-mv and equivalent git-rm+git-add;
it employs heuristic similarity based (based on how contents of files
is similar to each other) rename detection.

Also worth noting is that git does consider only endpoints for rename
detection in diff and in merge; it does not check history if there
were clean rename / rename + edit.

-- 
Jakub Narebski
Poland
ShadeHawk on #git

```
