3

数週間前にプロジェクトをフォークしました。メイン リポジトリはプライベート サーバー上にあります。

$ # on gitserver.com
$ git clone --bare main.com:myproject

アップストリーム リポジトリを追加し、新しいデータを取得しました。

$ # on desktop.com
$ git clone gitserver.com:myproject
$ git remote add upstream main.com:myproject
$ git fetch upstream

アップストリーム ブランチを自分のリモート リポジトリにプッシュしようとすると、アップストリームには存在するがオリジンには存在しないブランチのエラーが発生します。

$ 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 '...'

このリモートブランチをオリジンに作成してプッシュするにはどうすればよいですか?

4

2 に答える 2

1

これは、すべてのブランチを上流から起点 (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

「git fetch アップストリーム」ですべてのタグをローカルに取得できるため、すべてのタグをコピーする方が簡単でした。

git push --tags origin

これも私がやりたかったことの一部だったので追加しました。

于 2013-10-01T15:22:57.653 に答える
1

試す:

$ git push origin refs/remotes/upstream/BRANCH_A:refs/heads/BRANCH_A

それでもうまくいかない場合は、次を試してください。

$ git checkout BRANCH_A; git push origin BRANCH_A
于 2012-07-05T11:42:36.033 に答える