git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Sixt <j.sixt@viscovery.net>
To: xpr1010 <volition1980@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: Combining/merging commits
Date: Tue, 15 Apr 2008 08:37:09 +0200	[thread overview]
Message-ID: <48044D15.6040801@viscovery.net> (raw)
In-Reply-To: <8e0b7b96-aee8-45a4-a160-023e92845434@n1g2000prb.googlegroups.com>

xpr1010 schrieb:
> I have made several commits that should really have only been one, but
> there was a lot of back and forth because of my inherent clumsiness.
> Is there any way to combine or merge these commits to one?

Say, you have this commit series:

 ...--A--B--C--D

and you want to combine all of them, i.e. the last 4 commits, into a new
one, then you can do:

    # undo commits, but leave working directory unchanged
    $ git reset HEAD~4
    # make a new commit
    $ git commit

But if you want to combine only A,B,C because D should remain a separate
commit (i.e. what you want to combine are *not* the last commits), then
use git rebase --interactive, in particular, the 'squash' instruction. You
would use this todo list:

    pick A
    squash B
    squash C
    pick D

-- Hannes

  reply	other threads:[~2008-04-15  6:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-15  0:57 Combining/merging commits xpr1010
2008-04-15  6:37 ` Johannes Sixt [this message]
2008-04-15 12:43   ` xpr1010

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=48044D15.6040801@viscovery.net \
    --to=j.sixt@viscovery.net \
    --cc=git@vger.kernel.org \
    --cc=volition1980@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).