Unknown mailing list, 1.

Re: Edit log message after commit

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Junio C Hamano
Date: Wednesday, September 28, 2005 - 9:15 pm

Kevin Leung <hysoka@gmail.com> writes:


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.

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Edit log message after commit, Kevin Leung, (Wed Sep 28, 7:28 pm)
Re: Edit log message after commit, Junio C Hamano, (Wed Sep 28, 9:15 pm)
Re: Edit log message after commit, Tony Luck, (Wed Sep 28, 9:17 pm)
Re: Edit log message after commit, Brian Gerst, (Wed Sep 28, 9:58 pm)
Re: Edit log message after commit, Kevin Leung, (Thu Sep 29, 12:45 am)
Re: Edit log message after commit, Catalin Marinas, (Thu Sep 29, 1:35 am)
Re: Edit log message after commit, Yasushi SHOJI, (Thu Sep 29, 9:05 am)
Re: Edit log message after commit, Kevin Leung, (Fri Sep 30, 12:58 am)
Re: Edit log message after commit, Junio C Hamano, (Fri Sep 30, 1:24 am)