Thread (5 messages) flat view 5 messages, 4 authors, 2016-06-15

Re: Edit log message after commit

From: Yasushi SHOJI <hidden>
Date: 2016-06-15 22:42:07

At Thu, 29 Sep 2005 15:45:49 +0800,
Kevin Leung wrote:
But as Tony has pointed out. I would have needed to redo all the
subsequent commits if I was to change non-HEAD commit message. What
is the proper way of doing that? Is it the same as
Documentation/howto/revert-branch-rebase.txt ?
as pointed out by others, if the tree is already public, do revert.
otherwise, use git-cherry-pick and git-rebase might help.  but it
might not be a good idea. (don't know)

to illustrate this, create the following tree

c
|
b
|
a
|
initial

    git-init-db
    echo hello > hello.c
    git-update-index --add hello.c
    git-commit -v -m 'initial'
    echo a >> hello.c
    git-commit -a -m 'add a'
    echo b >> hello.c
    git-commit -a -m 'add b'
    echo c >> hello.c
    git-commit -a -m 'add c'

say, you want to edit the commit message for 'add a'.

first, create new branch at where you wanna change the message

    git checkout -b temp HEAD^^^   # hmm... HEAD^3 doesn't work

cherry pick the 'add a' commit but don't commit yet

    git-cherry-pick -n master^^

commit the change with reediting the original commit log

    git commit --reedit master^^

rebase the _master_ to temp

    git-checkout master
    git-rebase temp

I'm pretty sure that there is better way to do it and these should be
easy to be scripted.

my two cents,
--
          yashi
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help