You use a temporary branch for creating the commits that you want to inject
into earlier steps your tutorial. In git you can inject older commits by
using rebase. This is a tad complicated, but I just spent some minutes
figuring it out so might as well paste it :)
How can I inject topicA into master before B? So I get:
So, check out topicA branch. We'll first wind it back to (the tag) A in
master, and play our commits E-F-G on top of that:
> git rebase --onto A master
And now we replay the commits in master which are not in topicA:
> git rebase --onto topicA topicA master
Now, the result is in the fix-step-1 branch, so you can remove master and
rename the branch to be master instead.
*A much simpler approach* is to just work and commit normally in master, and
then rewrite history with git rebase --interactive. This provides you with a
really handy way of moving commits backwards in history, squashing them
together with other commits, editing old commits, etc.
Note that you should never rebase/rewrite history in a published repository.
You received this message because you are subscribed to the Google Groups "Git
for human beings" group.
To post to this group, send email to git-us...@googlegroups.com.
To unsubscribe from this group, send email to
For more options, visit this group at