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.

  • Android source code git download error
  • Find Last 10 authors for a certain file in Git
  • Heroku, like a git repo?
  • What is equivalent of git checkout branch_name on LibGit2Sharp
  • Reverting to previous commit non-destructively
  • Merge a branch with Git Flow keeping the branch still alive
  • If this exact question has been asked, please flag it and provide a link.

  • Git branching previous commits
  • Reverting most top n commits in git
  • Android Studio - CRLF vs LF for a Git-based multiplatform project
  • Should I commit .rvmrc files in a project?
  • Multiple SSH Keys on the same device
  • netbeans cordova- error while building my project
  • One Solution collect form web for “Git rebase first 2 Commit”

    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
    Git Baby is a git and github fan, let's start git clone.