# how to edit commit message in history

4 messages from 2009-01-16 to 2009-01-16. Participants: bill lam, Jike Song, thestar@fussycoder.id.au, Jakub Narebski.
Thread: https://gitlist.dev/t/17199

## bill lam, 2009-01-16 03:57

Subject: how to edit commit message in history
Message-ID: <20090116035714.GA6984@b2j>
URL: https://gitlist.dev/e/20090116035714.GA6984%40b2j

```
I made some typos in commit messages, how to edit them without
affecting everything else?

Thanks in advance.

-- 
regards,
====================================================
GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
唐詩311 無名氏  雜詩
    盡寒食雨草萋萋  著麥苗風柳映堤  等是有家歸未得  杜鵑休向耳邊啼

```

## Jike Song, 2009-01-16 04:09

Subject: Re: how to edit commit message in history
Message-ID: <df9815e70901152009i3bd717d0t6c20c41e9be19552@mail.gmail.com>
URL: https://gitlist.dev/e/df9815e70901152009i3bd717d0t6c20c41e9be19552%40mail.gmail.com
In-Reply-To: <20090116035714.GA6984@b2j>

```
On Fri, Jan 16, 2009 at 11:57 AM, bill lam <cbill.lam@gmail.com> wrote:
> I made some typos in commit messages, how to edit them without
> affecting everything else?
>
> Thanks in advance.

say, it's commit HEAD~2 to be revised.

    git rebase -i HEAD~3

In your editor, you all see something like this:

pick db79377 2nd
pick fa9ced8 3rd
pick b842e49 4nd

# Rebase 1423d77..b842e49 onto 1423d77
#
# Commands:
#  p, pick = use commit
#  e, edit = use commit, but stop for amending
#  s, squash = use commit, but meld into previous commit
#
# If you remove a line here THAT COMMIT WILL BE LOST.
# However, if you remove everything, the rebase will be aborted.
#



Now change "pick" to "edit" with your typo commit, save it and exit.
You will see something like this:

$ git-rebase -i HEAD~3
Stopped at db79377... 2nd
You can amend the commit now, with

        git commit --amend

Once you are satisfied with your changes, run

        git rebase --continue


Just follow the instructions.

-- 
Thanks,
Jike

```

## thestar@fussycoder.id.au, 2009-01-16 04:31

Subject: Re: how to edit commit message in history
Message-ID: <20090116153156.tfzar9idq8gwk0wg@webmail.fussycoder.id.au>
URL: https://gitlist.dev/e/20090116153156.tfzar9idq8gwk0wg%40webmail.fussycoder.id.au
In-Reply-To: <20090116035714.GA6984@b2j>

```
You can't, that would default the whole point of git's sha1 hashes!

If you change a commit, you will change the sha1 hash of that commit,  
and every subsequent commit. There is no way around it.

Quoting bill lam <cbill.lam@gmail.com>:

> I made some typos in commit messages, how to edit them without
> affecting everything else?
>
> Thanks in advance.
>
> --
> regards,
> ====================================================
> GPG key 1024D/4434BAB3 2008-08-24
> gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
> 唐詩311 無名氏  雜詩
>     盡寒食雨草萋萋  著麥苗風柳映堤  等是有家歸未得  杜鵑休向耳邊啼
> --
> 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
>

```

## Jakub Narebski, 2009-01-16 11:18

Subject: Re: how to edit commit message in history
Message-ID: <m34ozzzegn.fsf@localhost.localdomain>
URL: https://gitlist.dev/e/m34ozzzegn.fsf%40localhost.localdomain
In-Reply-To: <20090116035714.GA6984@b2j>

```
bill lam <cbill.lam@gmail.com> writes:

> I made some typos in commit messages, how to edit them without
> affecting everything else?

If it is last commit that you want to edit, and if you didn't publish
this commit to soem public repository, you can simply use

  $ git commit --amend

If the commit is deeper in history, use "git rebase --interactive".
If you published commit, you are out of luck.

See http://git.or.cz/gitwiki/GitTips
-- 
Jakub Narebski
Poland
ShadeHawk on #git

```
