Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does git call me "clever" when I reword the last commit message?

I regularly run

git commit --only --amend

to reword the commit message of the latest commit I made. This will work irrespective of whether my working directory is clean or not.

Today I noticed that when doing this, the default instructions for writing commit messages shown in my core.editor include the following comment:

# Clever... amending the last one with dirty index.

Aside from having a bit of an easter egg charm to it, what is this message supposed to tell me? Is it an ironic way of saying that I should be careful when messing with previous commits (esp. if there are staged/unstaged changes present)? And why does it show up even if my working directory is clean?

like image 703
itsjeyd Avatar asked Apr 22 '14 09:04

itsjeyd


People also ask

How do I reword a commit message in git?

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 ammend my last commit?

Changing the Last Commit: git commit --amend. The git commit --amend command is a convenient way to modify the most recent commit. It lets you combine staged changes with the previous commit instead of creating an entirely new commit.

What happens when you commit a change without giving any message?

If you commit without using the -m option, git will open your default text editor with a new file, which will include a commented-out list of all the files/changes that are staged in the commit.

What is reword in git?

"reword" allows you to change ONLY the commit message, NOT the commit contents. "edit" allows you to change BOTH commit contents AND commit message (the mechanism by which git allows you to edit the commit contents is by "pausing" the rebase; so you can amend the commit)


Video Answer


1 Answers

I think this might be the original commit message:

git-commit --amend: two fixes.

When running "git commit --amend" only to fix the commit log
message without any content change, we mistakenly showed the
git-status output that says "nothing to commit" without
commenting it out.

If you have already run update-index but you want to amend the
top commit, "git commit --amend --only" without any paths should
have worked, because --only means "starting from the base
commit, update-index these paths only to prepare the index to
commit, and perform the commit".  However, we refused -o without
paths.

Signed-off-by: Junio C Hamano <[email protected]>

I'm not very git proficient, but to me it does look like a genuine compliment for getting around the dirty index by using --only without paths

like image 88
monocell Avatar answered Oct 05 '22 01:10

monocell