From: Junio C Hamano <junkio@cox.net>
To: Kevin Leung <hysoka@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: Edit log message after commit
Date: Wed, 28 Sep 2005 21:15:20 -0700 [thread overview]
Message-ID: <7vr7b8pl0n.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: <dhfjcu$36f$1@sea.gmane.org> (Kevin Leung's message of "Thu, 29 Sep 2005 10:28:39 +0800")
Kevin Leung <hysoka@gmail.com> writes:
> Is there any method to edit the log message after committed? I
> couldn't find any information in Documentation and in git
> mailing list.
Undoing and re-committing can be done with the following
recipe.
There is a *big* *red* *warning*, though. If you have already
made available the commit you are about to undo to others, and
later other people have made more commits on top of them,
merging their changes back to your repository would make the
commit history look a bit funny. You could still do this
without damaging the repository. This warning only applies to
the shape of the commit graph.
First, the easiest case. Undoing and recommitting the latest
commit in the current branch.
(1) Run "git diff HEAD" and make sure that your working tree
matches the latest commit you are about to undo. Then:
$ git reset --soft HEAD^
This leaves the working tree intact (i.e. it still has what
you to have in the commit you are "fixing").
(2) Optional. If you wanted to make changes other than commit
log, do your edit here in the working tree. When done, run
"git diff HEAD" to make sure the changes are what you want
the "fixed" commit to have.
(3) Run:
$ git commit -c ORIG_HEAD
If you made changes in (2) and have not done
"git-update-index" on them, you may want to add '-a' there.
If you are just redoing the log message you probably would
not.
This gives you the editor with the log message from the
commit you undone in step (1). Do your edit and exit the
editor as usual.
Look at the output in "gitk HEAD ORIG_HEAD" to understand what
happened. You just rewound a commit, and made a different
commit.
Harder, more cumbersome case, is when you realize that you made
a mistake a several commits ago. This is described in detail in
Documentation/howto/revert-branch-rebase. Read it.
next prev parent reply other threads:[~2005-09-29 4:15 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-09-29 2:28 Edit log message after commit Kevin Leung
2005-09-29 4:15 ` Junio C Hamano [this message]
2005-09-29 4:17 ` Tony Luck
2005-09-29 4:58 ` Brian Gerst
2005-09-29 7:45 ` Kevin Leung
2005-09-29 16:05 ` Yasushi SHOJI
2005-09-30 8:24 ` Junio C Hamano
2005-09-29 8:35 ` Catalin Marinas
2005-09-30 7:58 ` Kevin Leung
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7vr7b8pl0n.fsf@assigned-by-dhcp.cox.net \
--to=junkio@cox.net \
--cc=git@vger.kernel.org \
--cc=hysoka@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).