1

I usually submit a list of commits for review. If I have the following commits:

HEAD     (not pushed)
Commit1  (not pushed) (Merged master here)
Commit2
Commit3
...

I know that I can modify head commit with git commit --amend. But how can I modify Commit1? given that it is not the HEAD commit and not pushed. git rebase does not show it in list of I enter git rebase -i HEAD~3.

Dexter
  • 31
  • 3

2 Answers2

1

Thank you for the answers, Actually the commit message I wanted to modify was merge commit and git rebase command does not show merge commits(if not pushed I guess) in rebase HEAD~n command and it was the main issue.

With the help of my colleague I was able to resolve by this command

git rebase -i -p HEAD~3

where -p is for preserve merges Still not able to understand how this works fully, but it did the job.

Dexter
  • 31
  • 3
0

If you:

You can use git filter-repo and its callbacks, based on the content of the old message:

git-filter-repo --message-callback '
  if b"known content" in message:
    message = "New message\npossibly on\n several lines""
  return message'
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250