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
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.
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.
To make origin/master
the default branch for remote origin
, and thus make git rebase origin
work:
$ echo "ref: refs/remotes/origin/master" > .git/refs/remotes/origin/HEAD
You need to provide the name of a branch (or other commit identifier), not the name of a remote to git rebase
.
E.g.:
git rebase origin/master
not:
git rebase origin
Note, although origin
should resolve to the the ref origin/HEAD
when used as an argument where a commit reference is required, it seems that not every repository gains such a reference so it may not (and in your case doesn't) work. It pays to be explicit.
git submodule deinit --all -f
worked for me.
I ran into this and realized I didn't fetch the upstream before trying to rebase. All I needed was to git fetch upstream