Reputation:
I forked a project a few weeks ago. The main repository is on a private server.
$ # on gitserver.com
$ git clone --bare main.com:myproject
Now I've added the upstream repo and fetched new data.
$ # on desktop.com
$ git clone gitserver.com:myproject
$ git remote add upstream main.com:myproject
$ git fetch upstream
When I try to push the upstream branches to my own remote repo, I get an error for branches that exist on upstream but not in origin.
$ git push origin refs/remotes/upstream/BRANCH_A:BRANCH_A
Everything up-to-date
$ git push origin refs/remotes/upstream/BRANCH_B:BRANCH_B
error: unable to push to unqualified destination: BRANCH_B
The destination refspec neither matches an existing ref on the remote nor
begins with refs/, and we are unable to guess a prefix based on the source ref.
error: failed to push some refs to '...'
How can I create this remote branch on origin and push to it?
Upvotes: 3
Views: 1087
Reputation: 11
This is what I used to copy all branches from upstream to origin (bash):
for i in .git/refs/remotes/upstream/*;
do
z=${i#.git/refs/remotes/upstream/};
git push origin refs/remotes/upstream/$z:refs/heads/$z;
done
Copying all tags was easier as "git fetch upstream" will give me all tags locally:
git push --tags origin
Added this as it was also part of what I wanted to do.
Upvotes: 1
Reputation: 12946
Try:
$ git push origin refs/remotes/upstream/BRANCH_A:refs/heads/BRANCH_A
if that doesn't work, try:
$ git checkout BRANCH_A; git push origin BRANCH_A
Upvotes: 1