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?

1

3 Answers 3

6

To rename a file with git use git mv

git mv oldname newname 
Sign up to request clarification or add additional context in comments.

1 Comment

Down voting for potentially miss leading
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.

Comments

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

1 Comment

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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.