Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the number in R{number} after a git rename mean?

Tags:

git

rename

I made the commit below. It basically shows a couple of files with static html getting renamed and moved.

commit 8449e207d529779f92bfe8b4eb2864a3f3edf69a
Author: Carl-Erik Kopseng <[email protected]>
Date:   Sat Nov 19 14:40:47 2016 +0100

    Integrate static html into epi blocks as partials

R079    Web/Views/Shared/Blocks/ChristmasLotteryBlock.cshtml    Web/Views/Shared/Blocks/ChristmasLotteryBlock/Index.cshtml
R076    Web/Static/blocks/_block_christmas-lottery-intro.html   Web/Views/Shared/Blocks/ChristmasLotteryBlock/_intro.cshtml
R099    Web/Static/blocks/_block_christmas-lottery-popup.html   Web/Views/Shared/Blocks/ChristmasLotteryBlock/_popup.cshtml
M       Web/Web.csproj

What does the 076, 099 and 079 refer to? I get that R probably stands for "Rename".

like image 517
oligofren Avatar asked Nov 20 '16 08:11

oligofren


People also ask

What does R in git mean?

I get that R probably stands for "Rename". git rename.

What happens if you rename a file in git?

Git keeps track of changes to files in the working directory of a repository by their name. When you move or rename a file, Git doesn't see that a file was moved; it sees that there's a file with a new filename, and the file with the old filename was deleted (even if the contents remain the same).

How does git detect rename?

Detect renames. If n is specified, it is a threshold on the similarity index (i.e. amount of addition/deletions compared to the file's size). For example, -M90% means Git should consider a delete/add pair to be a rename if more than 90% of the file hasn't changed.

What information does git status show?

The git status command displays the state of the working directory and the staging area. It lets you see which changes have been staged, which haven't, and which files aren't being tracked by Git. Status output does not show you any information regarding the committed project history.


1 Answers

Quoting the git diff documentation:

Status letters C and R are always followed by a score (denoting the percentage of similarity between the source and target of the move or copy). Status letter M may be followed by a score (denoting the percentage of dissimilarity) for file rewrites.

(You will only see M followed by a number if you are using the -B flag. Here is a somewhat contrived example of adding -B to cause an M status to have an appended score:

$ git diff --raw -M HEAD~182 | grep 'M[0-9]'
$ git diff --raw -B -M HEAD~182 | grep 'M[0-9]'
:100644 100644 2b1487d... bdb5579... M074   Makefile
:100644 100644 b639986... 8d8ebfe... M067   fcall.h
:100644 100644 bc4f828... 2e07ef6... M060   lib9p.h
:100644 100644 f9b5d18... 15e1ae8... M066   request.c

This particular repository has 184 first-parent commits starting from HEAD:

$ git rev-list --count --first-parent HEAD
184

with many—though not all—files appearing within the first few commits, so that comparing HEAD~182 to HEAD has many changes that result in many broken pairings when using -B.)

like image 134
torek Avatar answered Oct 07 '22 06:10

torek