Git mv does not delete the old file

I ran this:

$ git mv README README.md 

Then:

  $ git commit -m "renamed" README.md $ git push origin master 

But on github, the old old README file still exists in the repository. Why?

+4
source share
1 answer

Because you never did part of the removal of this move.

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

Added content can be specified in several ways:

...

3) by listing the files as arguments of the commit command, in which case the commit will ignore the changes made in the index, and instead write the current contents of the listed files (which git should already know);

Pay attention to the decisive bit here: it will ignore changes made to the index. git mv performs the step of both deleting the old file and creating a new one, but it does not. When you call git commit README.md , it writes a new version of the file, but ignores the phased deletion of the old file.

Try this sequence instead:

 $ git mv README README.md $ git commit -m "renamed" $ git push origin master 
+5
source

All Articles