Re: changing log entries

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Andy Parkins wrote:

> On Wednesday 2006 December 13 23:08, Jon Masters wrote:
> 
>> Anyway, now I would like to change an existing log entry to make it a
>> bit cleaner (read: add a first line that's under 80 characters). What's
>> the best way to change an existing log entry for a commit?
> 
> If it's HEAD you want to change:
>  git-commit --amend
> 
> If it's not, it's a bit harder.  You could pull each commit out as a patch and 
> apply them again later after a git-reset.  However, git has a tool for 
> automating a lot of that:  git-rebase.  man git-rebase has some excellent 
> examples.
> 
>  * -- A -- B -- C (master)
> 
> Let's say you want to edit A; make a new branch at A:
> 
> $ git branch temp-edit-branch master^^
>  
>  * -- A (temp-edit-branch)
>        \
>         B -- C (master)
> 
> Edit A with git-commit --amend.  This makes a new A, A' that has the new 
> commit message:
> 
>  * -- A' (temp-edit-branch)
>   \
>    A -- B -- C (master)
> 
> Then you switch to "master" and rebase master onto temp-edit-branch; you can 
> then delete temp-edit-branch
> 
> $ git-checkout master
> $ git-rebase temp-edit-branch

Theoretically you should do

$ git rebase --onto temp-edit-branch master^^ master

but thanks to automatic detection that patch is already applied the
above also should work. Well, unless you edit the commit so much
that git does not recognize it as the same commit...

> $ git branch -D temp-edit-branch
> 
>  * -- A' -- B' -- C' (master)
>   \
>    A -- B -- C

...in which case "git rebase temp-edit-branch master" would give you

  * -- A' --A* -- B* -- C* (master)
   \
    A -- B -- C

-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git


-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]