# git mv + git pull issue

3 messages from 2008-06-06 to 2008-06-09. Participants: Christoph Duelli, Johannes Schindelin.
Thread: https://gitlist.dev/t/13828

## Christoph Duelli, 2008-06-06 07:57

Subject: git mv + git pull issue
Message-ID: <4848EDDF.7090906@melosgmbh.de>
URL: https://gitlist.dev/e/4848EDDF.7090906%40melosgmbh.de

```
"git mv" followed by a git pull (before commiting) the move, loses the 
"remove" part of the move. This can lead to dupes in the repository.


Consider the following steps:

# create a new repo with a file in it
mkdir gitmv
cd gitmv/
git init
touch afile
git add afile
git commit -a -m"first"

# clone it
cd ..
git clone gitmv/ gitmv-clone
cd gitmv-clone/
touch other
git add other
git commit -a -m"other"

cd ../gitmv
git mv afile newname
# do not commit
# now: afile is not in the directory anymore
# oh, I need those changes my colleague made...
git pull ../gitmv-clone/
# now: both(!) afile and newname are in the directory

If I commit now (and overlook this) I will have 2 copies of this file in 
my repository which is not usually what I want.


Suggestion:
+ if the file was not touched in the pulled commits, leave it (missing)
+ if it was touched: this should be a conflict

Best regards
-- 
Christoph Duelli

```

## Johannes Schindelin, 2008-06-06 15:40

Subject: Re: git mv + git pull issue
Message-ID: <alpine.DEB.1.00.0806061639390.1783@racer>
URL: https://gitlist.dev/e/alpine.DEB.1.00.0806061639390.1783%40racer
In-Reply-To: <4848EDDF.7090906@melosgmbh.de>

```
Hi,

On Fri, 6 Jun 2008, Christoph Duelli wrote:

> cd ../gitmv
> git mv afile newname
> # do not commit
> # now: afile is not in the directory anymore
> # oh, I need those changes my colleague made...
> git pull ../gitmv-clone/
> # now: both(!) afile and newname are in the directory

What is so surprising there?  We _always_ recommend to commit before 
pulling.

Ciao,
Dscho

```

## Christoph Duelli, 2008-06-09 08:45

Subject: Re: git mv + git pull issue
Message-ID: <484CED98.3070506@melosgmbh.de>
URL: https://gitlist.dev/e/484CED98.3070506%40melosgmbh.de
In-Reply-To: <alpine.DEB.1.00.0806061639390.1783@racer>

```
Johannes Schindelin schrieb:
> Hi,
> 
> On Fri, 6 Jun 2008, Christoph Duelli wrote:
> 
>> cd ../gitmv
>> git mv afile newname
>> # do not commit
>> # now: afile is not in the directory anymore
>> # oh, I need those changes my colleague made...
>> git pull ../gitmv-clone/
>> # now: both(!) afile and newname are in the directory
> 
> What is so surprising there?  We _always_ recommend to commit before 
> pulling.
Well, when I modify a file, and pull afterwards: my 'modification' is 
never lost (the pull might fail, though).
If we consider the removal of a file as a kind of modification, one 
would expect a similar behaviour.

I do agree that this is not (nec.) a bug, still I thought it worthwhile 
to bring the matter up.
In our repository we get duplicates now and then because of it.

Regards
-- 
Christoph Duelli

```
