1

When I rename a file, git thinks that I've deleted the file and created another file. How can I rename a file, so that git knows I'm "renaming" it?

Nawal
  • 55
  • 4

3 Answers3

6

To rename a file with git use git mv

git mv oldname newname
jbr
  • 6,198
  • 3
  • 30
  • 42
4

git mv is just a convinience command as mentioned in git wiki

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 answer also tells about the same and some other use cases.

Community
  • 1
  • 1
abnvp
  • 1,037
  • 11
  • 19
2

In contrast to traditional SCMs, git track content instead of files,

more detailed description here: https://git.wiki.kernel.org/index.php/Git_FAQ#Why_does_Git_not_.22track.22_renames.3F

miushock
  • 1,087
  • 7
  • 19
  • 1
    This answer isn't really all that clear, it would be better if it had more explanation of how this relates to how Git knows that you've renamed a file. –  Mar 08 '14 at 22:41