How to change older commit messages that have already been pushed

Hey everyone, so I was able to change a commit message for commits that had not yet been pushed by using git commit --amend -m “new message text here.” Then I used git push --force to push it to GitHub. So far so good.

But now I want to change multiple commit message for files that have already been pushed to GitHub. According to the command to do this is:

git rebase -i HEAD~n 

where n = the number of recent files whose commit message you want to amend. I want to change the last 3 pushed files so I used git rebase -i HEAD~3 but said “could not execute editor” (see screenshot below). It doesn’t look like I have vi or vim or whatever I need. And by the way I’m using R studio cloud.

Appreciate any help,


Yeah, you can achieve that using rebasing, and you’re using the right command. However, Git needs to have access to a text editor so it can open that which allows you to change the messages.

You could try to

git config --global core.editor nano

use Nano and check if that is installed.

Otherwise use  git config (like the command above) and set it to the text editor of your choice ( nanovivim ) and then install that text editor and make sure it actually works by trying to open the one you chose. If, for example, you are using Ubuntu, do the following:

apt update
apt install nano
nano # this should open the editor up - then you know it works
# to get out of Nano use CTRL+X
1 Like