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?
>Solution :
You don’t have quite the right syntax.
Recall that:
-
The syntax of the
--fixupoption is--fixup=[(amend|reword):]<commit> -
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.