Reputation: 3616
I'm confused as to how to choose a commit message when rebasing in interactive git. I see this message:
Please enter the commit message for your changes. Lines starting
with '#' will be ignored, and an empty message aborts the commit.
I simply want to choose my first commit's existing message as the commit message of this rebase, but I'm confused as to how to accomplish this.
Upvotes: 2
Views: 1709
Reputation: 520908
If you want to change the message from a certain Git commit, you can use interactive rebase and choose reword
as the option next to that commit. For example, if you wanted to change the message from 4 commits ago you could do this:
git rebase -i HEAD~4
pick n3j9sj2 Comment for your most recent commit
pick b9de4la Comment for next most recent commit
pick 78er2nm Comment for an older commit
reword k2nbet3 Here is the commit you want to change
Now when the editor screen comes up (which you referenced in your question), you can enter whatever commit message you want. When you save and exit, the message for the commit whose SHA-1 is k2nbet3
should be changed.
Note that you will have to force push your branch out to the remote via:
git push --force origin branch_name
Doing a force push can potentially cause some problems for everyone else using the branch so think carefully before you do this.
Upvotes: 4