francium francium - 1 year ago 114
Git Question

Git rebase first 2 Commit

Here is what I have done so far. And what I'm trying to do is merge the first and second commits into a single commit before I push (have not added remote repository yet).

$ git init

$ vim myprogram

$ git add myprogram && git commit -m "Initial commit"

$ vim

$ git add && git commit -m "Added readme"

$git log --pretty=oneline
b8e2979 Added readme
a579d65 Initial commit

$ git rebase -i HEAD~2
fatal: Needed a single revision
invalid upstream HEAD~2

What have I done wrong that is causing the fatal error.

If this exact question has been asked, please flag it and provide a link.

Answer Source

You want to use the --root option:

... Rebase all commits reachable from <branch>, instead of limiting them with an <upstream>. This allows you to rebase the root commit(s) on a branch. ...

git rebase -i --root
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download