1

Lets assume a scenario that i have a remote, a developer1 and a developer2. Developer1 pushes his project in the remote. Developer2 clones the project from the remote,and he renames a file, and puts it in another folder.Then he pushes the project to the remote. Then developer1 fetches the project from the remote.

In that case, will the renaming mechanism of git recognize that my renamed file is on that other folder?

mkounal
  • 773
  • 2
  • 7
  • 23

1 Answers1

0

Git has a very good mechanism for detecting file renames/moves. If the content of the file isn't changed to much (I think 90% of the content need to be the same) git will detect this as a move/rename. This will be shown like this in the commit message:

file.txt -> folder/file.txt

If git didn't detect the file move (because to much of the file was changed) you can tell that to git by doing:

git mv file.txt folder/file.txt

This way you can be sure that moving the file is detected.

Either way each operation of developer2 will be done to your local copy of the code, including renames, when you are pulling in the changes.

egore911
  • 438
  • 3
  • 9
  • Using `git mv` won't have any effect on the move detection used by git's diff engine. – CB Bailey Jun 30 '12 at 21:00
  • You are right, @charles-bailey. But what really works is doing "git mv file.txt folder/file.txt" first and than doing the actual changes to folder/file.txt – egore911 Jun 30 '12 at 21:10