Re: Splitting a commit with rebase -i and keeping a commit message

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

 



Taking a wild guess here...

On Tue, Apr 16, 2013 at 6:38 PM, Tim Chase <git@xxxxxxxxxxxxxxxxx> wrote:
> I asked this on IRC and played with some of their ideas, but struck
> out with anything satisfying.  I walked through [1] with the
> following setup:
>
>   git init foo
>   cd foo
>   touch a.txt b.txt
>   git add a.txt b.txt
>   git commit -m "Initial checkin"
>   echo "Modify A" >> a.txt
>   git commit -am "Modified A"
>   echo "Modify B" >> b.txt
>   git commit -am "Modified B"
>   echo "Modify A2" >> a.txt
>   echo "Modify B2" >> b.txt
>   git commit -am "Modified B"
>   git commit -am "Long-bodied commit comment about b.txt changes"
>   # whoops, just wanted B

Save the commit's ID here so that we can reuse its message later:

    orig_commit=$(git rev-parse HEAD)

>   git rebase -i HEAD^^
>   # change the "Added b.txt..." commit to "edit"
>   git reset HEAD^  # pull the changes out of the pending commit
>   git add a.txt
>   git commit -m "Tweaked a.txt"
>   git add b.txt
>   git commit ${MAGIC_HERE}

...reuse the commit message by passing the "-c" option to "git commit":

    git commit --reset-author -c $orig_commit

This will give you a chance to further edit the message in your editor.

>   git rebase --continue
>
> I haven't been able to figure out a good way to keep the "long-bodied
> commit comment" for the final commit where the ${MAGIC_HERE} is.  Is
> there a right/easy way to go about pulling in the commit-message from
> the commit the rebase is transplanting?

This is pretty much what the commands above do.
They save the commit ID so that we can reuse the message later.

HTH,
--
David
--
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]