git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: John Keeping <john@keeping.me.uk>
To: Robert Dailey <rcdailey.lists@gmail.com>
Cc: Git <git@vger.kernel.org>
Subject: Re: Adding a commit to the front of my branch?
Date: Mon, 11 Jan 2016 14:16:12 +0000	[thread overview]
Message-ID: <20160111141612.GK14056@serenity.lan> (raw)
In-Reply-To: <CAHd499B8gRMVWnUBZ0aO2RtokYqTm6fO7+7zfbsJNTnKw4MVsQ@mail.gmail.com>

On Mon, Jan 11, 2016 at 07:36:25AM -0600, Robert Dailey wrote:
> Normally to add commits on my branch, I perform an interactive rebase:
> 
> $ git rebase -i origin/master
> 
> I mark the commit I want to put the new commit on top of as 'edit'.
> However, if I want to add a commit to the front of my branch, I don't
> really have a commit to mark as "edit". I tried to be tricky with
> this, and did:
> 
> $ git rebase -i origin/master^
> 
> However this doesn't work if my merge-base is a merge commit. I get a
> ton of superfluous commits in my TODO file.
> 
> Is there a built-in mechanism I can use, with relative ease, to
> accomplish this goal? At the moment I have to run a series of a couple
> of commands to do this, namely mark the oldest commit on my branch as
> 'edit', reset it, stash it, add new commit, pop stash, commit again,
> etc.
> 
> Normally I'd add a new tip commit and reorder it to accomplish this,
> however commits on my branch already alter this code and I don't want
> to create unnecessary conflicts during rebase. The patch needs to be
> based on merge-base.

Have you considered creating a new (temporary) branch based on master,
adding the new commit there and inserting "pick $new_commit_sha1" at the
start of the instruction sheet when rebasing the original branch?

  parent reply	other threads:[~2016-01-11 14:16 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-11 13:36 Adding a commit to the front of my branch? Robert Dailey
2016-01-11 14:11 ` Stefan Haller
2016-01-13 16:18   ` Robert Dailey
2016-01-13 16:40     ` Stefan Haller
2016-01-13 17:19       ` Robert Dailey
2016-01-11 14:16 ` John Keeping [this message]
2016-01-13 16:21   ` Robert Dailey

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=20160111141612.GK14056@serenity.lan \
    --to=john@keeping.me.uk \
    --cc=git@vger.kernel.org \
    --cc=rcdailey.lists@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).