Re: Adding a commit to the front of my branch?
- From
John Keeping <john@keeping.me.uk>
- Date
- Jan 11, 2016, 14:16 UTC
- Message-ID
- <20160111141612.GK14056@serenity.lan>
- In-Reply-To
- <CAHd499B8gRMVWnUBZ0aO2RtokYqTm6fO7+7zfbsJNTnKw4MVsQ@mail.gmail.com>
On Mon, Jan 11, 2016 at 07:36:25AM -0600, Robert Dailey wrote:
Show 24 quoted lines
> 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?