I have a branch of a public repository and I am trying to update my branch with the current commits from the original repository:
$ git fetch <remote>
remote: Counting objects: 24, done.
remote: Compressing objects: 100% (20/20), done.
remote: Total 20 (delta 12), reused 0 (delta 0)
Unpacking objects: 100% (20/20), done.
From git://github.com/path_to/repo
9b70165..22127d0 master -> $/master
$ git rebase <remote>
fatal: Needed a single revision
invalid upstream <remote>
The <remote>
is in place of my remote name and is not actually my remote name. The documentation on this error seems to be a bit loose.
The error occurs when your repository does not have the default branch set for the remote. You can use the git remote set-head
command to modify the default branch, and thus be able to use the remote name instead of a specified branch in that remote.
To query the remote (in this case origin
) for its HEAD
(typically master
), and set that as the default branch:
$ git remote set-head origin --auto
If you want to use a different default remote branch locally, you can specify that branch:
$ git remote set-head origin new-default
Once the default branch is set, you can use just the remote name in git rebase <remote>
and any other commands instead of explicit <remote>/<branch>
.
Behind the scenes, this command updates the reference in .git/refs/remotes/origin/HEAD
.
$ cat .git/refs/remotes/origin/HEAD
ref: refs/remotes/origin/master
See the git-remote man page for further details.
git submodule deinit --all -f
worked for me.
The issue is that you branched off a branch off of.... where you are trying to rebase to. You can't rebase to a branch that does not contain the commit your current branch was originally created on.
I got this when I first rebased a local branch X to a pushed one Y, then tried to rebase a branch (first created on X) to the pushed one Y.
Solved for me by rebasing to X.
I have no problem rebasing to remote branches (potentially not even checked out), provided my current branch stems from an ancestor of that branch.
I ran into this and realized I didn't fetch the upstream before trying to rebase. All I needed was to git fetch upstream
Check that you spelled the branch name correctly. I was rebasing a story branch (i.e. branch_name
) and forgot the story part. (i.e. story/branch_name
) and then git spit this error at me which didn't make much sense in this context.
Source: Stackoverflow.com