WestCoastProjects
WestCoastProjects

Reputation: 63022

Git: fatal: Needed a single revision even though repo/revision both supplied

I have added a remote "upstream" repo reference to a local clone:

git remote add upstream https://github.com/<owner>/<repo>

Then did a remote fetch

git fetch upstream -a

Then the following attempt to rebase:

git rebase upstream/master

Gave us:

fatal: Needed a single revision

We can see the upstream:

$git branch -r
upstream/master

Git status shows us on master:

 $git status
 On branch master

 Initial commit

 nothing to commit (create/copy files and use "git add" to track)

What is needed here?

Upvotes: 2

Views: 5631

Answers (1)

twalberg
twalberg

Reputation: 62369

This git status output:

$ git status
On branch master

Initial commit

nothing to commit (create/copy files and use "git add" to track)

indicates that this is a new repository with an "unborn master branch" - no commits have been made.

Because there are no commits on master to actually rebase, then git rebase should not be expected to work (there are several other caveats or other things that work differently in this "unborn branch" state, as well).

In this case, if your goal is for "master" to reference the same commit as "upstream/master", this is probably the best way to do that:

git reset --hard upstream/master

Upvotes: 3

Related Questions