0

I have a git history like this:

date|commit hash|message
2015 10:00|12345|first commit
2015 10:05|12346|second commit
2015 10:10|12347|third commit
2015 10:15|12347|fourth commit

All of these commits are pushed. What's is the best way to change message of the commit with hash "12346" from "second commit" to "second commit changed"?

I am looking for simplest solution without rebasing or creating a new branch; just changing the commit message. I think that this wouldn't impact others even if someone fetch this because the commit will still have the same content and hash (only message will be different).

EDIT:

My question is not like: Changing git commit message after push (given that no one pulled from remote) because there is solution for last commit and I am looking for commit that is deper history.

Community
  • 1
  • 1
fico7489
  • 7,931
  • 7
  • 55
  • 89
  • there is answer for last commit, I am not looking for last commit. I am looking to edit commit from deeper history. – fico7489 Nov 27 '15 at 14:40
  • You can edit the message of an old commit with `git rebase -i ...`, but you'll be rewriting history. There's no way around this. – Joseph Silber Nov 27 '15 at 14:42
  • @fico7489 you're looking for a solution to a more general problem than the one in the linked to in the earlier comment, but the answer is the same: you cannot do it without rewriting history, as changing the message changes the hash. – Joost Nov 27 '15 at 14:49
  • Thank you Joost, your answer is solution to my problem, I haven't know that message is part of hash creating. – fico7489 Nov 27 '15 at 14:58

1 Answers1

2

This is not possible. A commit is the culmination of many things, including its message.

Changing the message would change the hash, which means it's a new commit. This would change history.

Joseph Silber
  • 214,931
  • 59
  • 362
  • 292