Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does it mean when Git says 'rewrite' or 'rename' in a commit message?

Tags:

git

git-commit

Running a git commit leads to the following output:

[manu@host] git: git commit -a -m "StreamIt instrumentation" [master 263410f] StreamIt instrumentation 62 files changed, 6117 insertions(+), 5748 deletions(-) rewrite Code/ALCHEMY/streamit-src-2.1.1/src/at/dms/kjc/cluster/ClusterBackend.java (91%) rewrite Code/ALCHEMY/streamit-src-2.1.1/src/at/dms/kjc/cluster/ClusterCodeGenerator.java (95%) rewrite Code/ALCHEMY/streamit-src-2.1.1/src/at/dms/kjc/cluster/code/FlatIRToCluster.java (94%) rewrite Code/ALCHEMY/streamit-src-2.1.1/src/at/dms/kjc/common/ToCCommon.java (92%) rewrite Code/ALCHEMY/streamit-src-2.1.1/src/at/dms/kjc/flatgraph/ScheduledStaticStreamGraph.java (93%) rename Code/ALCHEMY/streamit-src-2.1.1/src/at/dms/kjc/sir/lowering/fission/{StatelessDuplicate.java => HorizontalFission.java} (98%) rewrite Code/ALCHEMY/streamit-src-2.1.1/src/at/dms/kjc/sir/lowering/partition/dynamicprog/DynamicProgPartitioner.java (93%) 
  • What does git mean when it reports a file as 'rewrite'?
  • What is the meaning of the associated percentage?
  • Why is a percentage only associated with these lines among the 62 changed in this commit?
like image 987
Manuel Selva Avatar asked Nov 30 '12 08:11

Manuel Selva


People also ask

How do I rewrite a commit message?

On the command line, navigate to the repository that contains the commit you want to amend. Type git commit --amend and press Enter. In your text editor, edit the commit message, and save the commit.

How do I change a commit in git?

There are many ways to rewrite history with git. Use git commit --amend to change your latest log message. Use git commit --amend to make modifications to the most recent commit. Use git rebase to combine commits and modify history of a branch.

How do I amend a commit message after push?

Changing the latest Git commit message If the message to be changed is for the latest commit to the repository, then the following commands are to be executed: git commit --amend -m "New message" git push --force repository-name branch-name.


1 Answers

Git uses heuristics to determine if a change was a renaming or copying of a file, and also if it is a "rewriting" of the file. Roughly speaking, if the diff between the old and new version is bigger than the new version itself, it's a "rewrite".

This is tuned for git's original use case of changing source files, most often making localised changes: since it is based on a line-by-line diff, things like reindenting a source file can trigger it. Also, since it is determined on-the-fly, diff options like "-b" and "-w" can change the evaluation of whether a change is a rewrite (or a copy, or a rename).

The percentage is git's "dissimilarity index" (as opposed to the percentage "similarity index" for a rename or copy). Probably something like the percentage of lines in the file that have changed.

like image 60
araqnid Avatar answered Oct 02 '22 16:10

araqnid