Reputation: 4697
I have a repo that has not been associated with the repo I would like to push it to. After vetting, we are ready to submit it for comment at work.
first, I added the upstream repo I would like to push it to:
git remote add upstream [email protected]:v3/place/projectgroup/repo
This is the first and only upstream added, as before that it has lived only on my Mac. then I try to add the upstream:
$ git branch --set-upstream-to origin/candidate/1.0
error: the requested upstream branch 'origin/candidate/1.0' does not exist
hint:
hint: If you are planning on basing your work on an upstream
hint: branch that already exists at the remote, you may need to
hint: run "git fetch" to retrieve it.
hint:
hint: If you are planning to push out a new local branch that
hint: will track its remote counterpart, you may want to use
hint: "git push -u" to set the upstream config as you push.
$ git push -u origin/candidate/1.0 HEAD
fatal: 'origin/candidate/1.0' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
My question is, how do I push my current branch up to a remote repo using an upstream name that does not already exist?
Upvotes: 2
Views: 4019
Reputation: 535989
Let's say you are on branch mybranch
. Then you say
git push -u upstream mybranch
That means: "Take my local mybranch
, push it up to the upstream
remote (where it too will be called mybranch
), and at the same time, give me a tracking branch that will act as a linkage between the local mybranch
and the remote mybranch
."
If you want the remote name to be different from the local name, use colon syntax, e.g. mybranch:remotebranch
. (You might actually have to say mybranch:refs/heads/remotebranch
, I'm a little confused about that.)
Upvotes: 5