git rebase to _insert_ commits?

Misha Koshelev misha680 at gmail.com
Fri Jul 9 21:38:10 CDT 2010


On Fri, 2010-07-09 at 21:02 -0400, Mike Kaplinskiy wrote:
> You can move commits around in an interactive rebase. Just create an
> empty commit, move it into place with rebase and edit it.
> 
> Sorry for top post, mobile gmail doesn't let you bottom post.
> 
> > On Jul 9, 2010 8:56 PM, "Misha Koshelev" <misha680 at gmail.com> wrote:
> > 
> > Dear All:
> > 
> > I am still learning git and it seems that my solution does not quite
> > work.
> > 
> > Specifically, my idea was to use:
> > git rebase -i upstream/master
> > 
> > Mark the commit _after_ which I'd like to insert a commit with edit.
> > 
> > Then, when I am at that commit, I do:
> > 
> > git commit --amend -a
> > 
> > save commit
> > 
> > Then, _before_ doing git rebase --continue, I edit files and again
> > do:
> > 
> > git commit -a -n
> > 
> > Finally I do:
> > 
> > git rebase --continue
> > 
> > The problem is that this seems to squish further commits, and leads
> > to
> > problems which I am now trying to untangle.
> > 
> > However, as I still cannot insert a commit, I am not sure how to
> > proceed, except by creating a whole new repository.
> > 
> > Any ideas/hints?
> > 
> > Thank you
> > Misha
> > 
> > 
> > 
> 

Thank you. Btw I figured this out except for one caveat.

If I actually create an empty commit:
git commit --allow-empty -m "Empty commit"

and move it around using:
git rebase -i upstream/master

I get this error:
Finished one cherry-pick.
# Not currently on any branch.
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#	dlls/d3dx9_36/domake
#	dlls/d3dx9_36/tests/a
#	dlls/d3dx9_36/tests/docrosstest
#	dlls/d3dx9_36/tests/domesh
#	out/
nothing added to commit but untracked files present (use "git add" to
track)
Could not apply fb034a9... Empty commit

However, if I make a non-empty commit (say a single whitespace change)
then I am indeed able to do what you suggested.

Can I truly do this with an empty commit?

Thank you
Misha




More information about the wine-devel mailing list