1

I am renaming a file that I have earlier saved in my git repository. The status shows that one file has been added and another file has been removed. Do I need to remove and add to get the stat to commit correctly? If I don't add, will the repository save two images on the next commit, and then revert to a state with two images in the future (if I decide to revert back to the state I just committed ?)

Hoytman
  • 1,722
  • 2
  • 17
  • 29
  • You can use 'git mv' which will rename it http://stackoverflow.com/questions/2641146/handling-file-renames-in-git – Nick Apr 18 '14 at 18:34
  • possible duplicate of [Renaming a file without using rm in git](http://stackoverflow.com/questions/23160263/renaming-a-file-without-using-rm-in-git) – Nikhil Gupta Apr 18 '14 at 19:20

1 Answers1

2

The correct way of moving a file under git is to use git to do it for you:

git mv old.txt new.txt

However, if you add the new file and remove the old one from git, you should get the same effect:

git add new.txt
git rm old.txt
Mureinik
  • 297,002
  • 52
  • 306
  • 350