Reputation: 964
I did the following:
git fetch --all
git checkout -b my-feature-branch master
// did some edits
git commit -m "some commit comments"
git rebase another-branch
I get git error: "invalid upstream 'another-branch'
I can see the 'another-branch' on the remote so I am not sure what is happening. Any help is really appreciated.
Upvotes: 26
Views: 57351
Reputation: 4636
or maybe there is no main branch indeed. Maybe you have two projects opened and you are on wrong project where no main exists.
Upvotes: 0
Reputation: 2631
For me, I had a really old feature branch and ran into this error even though I ran a fetch in advance. I solved it by checking out the new (just fetched) release branch, checking the feature dev branch out again, and then doing the rebase.
$ git fetch --all
...
010c8a1..48202ec release/new -> origin/release/new
...
$ git branch
...
* dev/featurebranch (currently based on 'release/old')
$ git rebase release/new
fatal: invalid upstream 'release/new'
$ git checkout release/new
branch release/new set up to track origin/release/new by rebasing.
Switch to a new branch 'release/new'
$ git checkout dev/featurebranch
switched to branch...
$ git rebase release/new
Successfully rebased and updated refs/heads/dev/featurebranch
I think, but am not sure, that the crux of why the second rebase worked is that branch <name> set up to track origin/<name> by rebasing
created a local release branch to follow the origin release branch, which is what the local dev branch is technically rebased on top of.
Upvotes: 2
Reputation: 3343
Cherry pick to the rescue (again)
In my case, I had two branches with no common ancestor. (It was a new repo created on the server by admin staff but I wanted to get a head start on what I was building locally).
After adding a remote named 'origin' and fetching main
branch, I needed to rebase my wholly-local branch (spike
) onto the fetched branch (main
).
My solution was to cherry pick all my commits from spike
onto main
.
Upvotes: 1
Reputation: 32458
You need to checkout 'another-branch' locally before rebasing it.
git checkout -b another-branch origin/another-branch
Or, you need to pull all the branch after fetching
git pull --all
Upvotes: 30