I'm trying on a certain project to reword the penultimate commit to fix a typo by running git rebase -i HEAD~3
, (using the "nano" editor) then changing the default pick
option of that commit to r
or reword
(on the initial rebase file window), and, without modifying anything else. I'm doing it on the master
branch, if useful.
As soon as I save the file, Git, instead of showing me the next rebase window to pick a new name for that commit as usual, it puts itself and informs me of a detached HEAD state with that commit, that is also shown upon git status
command from then on, until I type git checkout master
.
No matter how many times I try, the same thing happens.
Additional note: I had previously changed the used editor to "nano" by running the single command: git config --global core.editor nano
EDIT: As requested, this is the message that Git gives me when I save the TODO list:
adrian$ git rebase -i HEAD~1
Note: checking out 'da91bbcedc78cb2ebcaa9dc51f38c8d0a550195d'.
You are in 'detached HEAD' state. You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may do so (now or later) by using -b with the checkout command again. Example:
git checkout -b
HEAD is now at da91bbc... Test message
This repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting .git/hooks/post-checkout. could not detach HEAD
Output after running git rebase --continue
at this point:
No rebase in progress?
The detached HEAD message appears normally when you put edit
in the to-do file for the interactive rebase. You must have mistakenly put edit
there instead of reword
. Or Git might have entered this mode (which is also entered in conflicts) due to the error found in your output:
This repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting .git/hooks/post-checkout. could not detach HEAD
You should resolve this error before continuing. Git tells you what to do.
The edit
mode allows modifying the commit message like reword
mode but also the file contents. Therefore Git left you in a state where you can commit changes and then continue rebasing using git rebase --continue
.
reword
) in the edit
modeWhen you want to just edit the commit message and continue rebasing, run
git commit --amend
which opens the editor to let you edit the commit message. After you have finished, run
git rebase --continue
As soon as I save the file, Git, instead of showing me the next rebase window to pick a new name for that commit as usual, it puts itself and informs me of a detached HEAD state with that commit, that is also shown upon
git status
command from then on, until I typegit checkout master
.
This is not the correct way of leaving unfinished rebase, you should use
git rebase --abort
instead.