1

Some files name has been changed in the project. Project is maintained using git. How can I get this information ?

I know that we can rename the files in git using git mv command. but Can i check this formation for previously renamed file (in older commits).

saurabh agarwal
  • 2,124
  • 4
  • 24
  • 46

1 Answers1

2

Git does not track files, but it tracks content that happens to be stored in files. This is the cause why you cannot track empty directories, as there is no content inside them, just files and also the cause why there is no explicit copy or rename tracking in git. Renames and copies are determined dynamically in git and in the commands that could be interested like git log or git diff, you can control whether renames and copies are detected and how much change in a file is still considered a rename or copy. The git mv operation is just a convenience synonym for the deletion of the old file and addition of the new file.

Vampire
  • 35,631
  • 4
  • 76
  • 102
  • Can i see which files are created and which files are deleted in a particular commit ? – saurabh agarwal Jan 23 '17 at 10:04
  • 1
    @saurabhagarwal `--stat` flag – hjpotter92 Jan 23 '17 at 10:13
  • 2
    There are plenty ways, depending on what exactly you want to see. e. g. `git show --name-status --diff-filter=ACDR` will show you added, copied, deleted and renamed files of the given commit-ish, including commit metadata like message. For only the list of files, you can do `git diff ^! --name-status --diff-filter=ACDR` – Vampire Jan 23 '17 at 11:11
  • I think now (2021) Git allows us to control whether to check renames or consider copies as renames, as well as the threshold. Search "rename" in git-status and git-diff doc. – K. Symbol Dec 16 '21 at 07:51
  • @K.Symbol yep, no change though. That's exactly what I answered. There is no explicit copy or rename, but it is dynamically determined in relevant commands with configurable thresholds. – Vampire Apr 05 '23 at 18:26