git > on committing renamed files
The aim is documenting renaming in git. The case is the renaming of files in the context of blogging for various reasons — a major change sometimes is followed by the bump of the timestamp necessary for Jekyll. I have used prefixes within filenames for semantic/versioning reasons, etc
commit rename automatically
- rename file
- stage the renamed file and nothing else
- commit with
commit -a -m <commit message>
flag or (commitcommit --all -m <commit message>
)
Tell the command to automatically stage files that have been modified and deleted, but new files you have not told Git about are not affected.
- Git — git-commit Documentation
▶ git log --pretty=format:"%h%x09%an%x09%ad%x09%s" --name-status --date=short 91695bb pavol kutaj 2020-07-08 staleness R078 _posts/2020-06-02-staleness.md _posts/2020-07-08-staleness.mdmaster ↑1 +16 ~0 -1 ! ⚡ 2 minutes ago
▶ git add 2020-07-09-git-rename-and-commit.md master ↑1 +1 ~0 -0 | +15 ~0 -1 ! ⚡ 2 minutes ago
▶ git commit -a -m "rename example"
[master 78102c8] rename example 1 file changed, 0 insertions(+), 0 deletions(-) rename _posts/{2020-07-08-git-rename-and-commit.md =>
2020-07-09-git-rename-and-commit.md} (100%) master ↑2 +15 ~0 -0 ! ⚡ 0 seconds ago
▶ git log --pretty=format:"%h%x09%an%x09%ad%x09%s" --name-status --date=short 78102c8 pavol kutaj 2020-07-08 rename example
R100 _posts/2020-07-08-git-rename-and-commit.md _posts/2020-07-09-git-rename-and-commit.md
benefits
- the workflow below is faster than having to
- stage an addition of new an with
git add <old_name>
- stage a removal of old file with
git add <new_name>
r100 status — and similar
The documentation for git status under “Changed Tracked Entries” appears to explain what R100 means: The rename or copy score (denoting the percentage of similarity between the source and target of the move or copy). For example “R100” or “C75”. So, putting this together with what you cited above, the files you are seeing with R100 status mean that they were moved, and that Git found a 100% match between that file and some other previously named file.
Originally published at Pavol’s github KB.