Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Having difficulty in selecting commit by message instead of hash for –fixup

I was looking for a way to select commits using the commit message instead of the relation from HEAD or the commit hash and found that it was possible, but I cannot get it to work.

I do have a previous commit, which has a commit message that starts with "Enable git rebase –autosquash" (as an example).

$ git add -u
$ git commit --fixup=amend:/'Enable git rebase --autosquash' -m "New message example"
fatal: could not lookup commit /Enable git rebase --autosquash

As I said, there is a commit which has a message which starts with that string. What am I doing wrong here?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You don’t have quite the right syntax.

Recall that:

  1. The syntax of the --fixup option is --fixup=[(amend|reword):]<commit>

  2. The syntax for specifying a commit by string is :/<string>.

If you replace <commit> in the first rule with the syntax from the second rule, you get:

git commit --fixup=amend::/'Enable git rebase --autosquash'

Note the two colons.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading