2016-12-30 7 views
0

私は既存のレポを持っています。私は既存のレポの特定のブランチに新しいファイルをプッシュ

git init 
git add . 
git commit -m "second commit" 
git remote add origin http://github.com/myusername/abc/tree/otherbranch 

しかしgit checkout otherbranchを試してみましたotherbranch

と呼ばれる私のレポの非masterブランチにいくつかの新しいファイルをプッシュすることは

error: pathspec 'otherbranch' did not match any file(s) known to git. 

git push origin otherbranch

error: src refspec otherbranch does not match any. 
error: failed to push some refs to 'https://github.com/myusername/abc/tree/otherbranch' 
を与えています

私は間違って何をしていますか?

答えて

1

git fetchを試してからgit checkout otherbranchとしてください。 Fetchは原点からのリファレンスをダウンロードします。そうしないと、ローカル作業コピーはotherbranchについて知りません。

https://git-scm.com/docs/git-fetch

EDIT

@anoeが指摘したように、それはブランチ名が含まれているとして、原点URLが間違っています。あなたは

git remote set-url origin https://github.com/myusername/abc.git

を行うことによって、誤った起源を修正する必要が続いなどプッシュし、コミット、チェックアウトをフェッチん

`致命的与えたfetch`
+0

' gitの:リポジトリ「をhttp://github.com/ myusername/abc/tree/otherbranch/'not found' – user5739619

+0

あなたが正しいです - 起源の場所が間違っています、それは 'https:// github.com/myusername/abc.git'のように見えるはずです。ブランチ名は含めないでください。 (原点の問題に気づくために@anoeに寄付をしています)正しい原点を設定したら、まだ取り出す必要があります。 – manannan

+0

'git remote add origin https:// github.com/myusername/abc.git'と入力すると' fatal:remote origin already exists'と表示されます。 'git fetch'を実行しようとすると' fatal:repository 'https://github.com/myusername/abc' not found'と表示されます – user5739619

関連する問題