I have a question about renaming files in git.
I want to rename a file. So I rename it. As far as i understand if I don't change the content of the file git will detect the move because the hash of the file is the same.
I'm using C++, so after the rename I have to change the include path in the file (which I have renamed), so the problem is that git does not detect the move, but instead thinks that one file was deleted and the other added. I'm looking for an solution where git detects this change.
Does anybody has a good strategy for that?
Thanks in advance
Tonka
If you want to have two different commits, one with move and second one with file changes, you should use git mv
and commit. Then change your include path and do another commit with inside file changes.
I'm using Java, with Java-Classes its the same, the contents change if you rename/move it (package
declaration, Class-Name).
Without doing something special, git recognized the rename, i can see the full history of the file.
In the commit, where i moved the file, i can see this (via eGit History in Eclipse):
diff --git a/Project/src/de/package/app/DebugInfo.java b/Project/src/de/package/app/development/DebugInfo.java
similarity index 88%
rename from Project/src/de/package/app/DebugInfo.java
rename to Project/src/de/package/app/development/DebugInfo.java
index 46494da..f90778e 100644
You can also adjust the Similarity Index, so git might recognize renamed files earlier.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With