2017-02-04 7 views
2

masterブランチからフィーチャーブランチを作成し、ブランチに追加してコミットしました。エラー:src refspec my-branchが一致しません

私の仕事をリモートのリポジトリにプッシュしたいのですが、失敗しました。問題を解決するために私は何ができますか?ありがとう。

git pushコマンドを実行しているときに、パスワードを要求しませんでした。それは普通ですか?

p.s.私はWindows 10のcmdを使用しています。

> git push origin my-branch 
error: src refspec my-branch does not match any. 
error: failed to push some refs to 'https://git.xxx.net/Infrastructure' 


>git commit -m "my work" 
On branch my-branch 
nothing to commit, working tree clean 

>git branch 
    master 
* my-branch 

>git show-ref 
687f22d54b89e0de91f16cf79d52c6ea21a3f562 refs/heads/master 
f85d2aa0900fb356d8d120f454ff2362d7475edb refs/heads/my-branch 
687f22d54b89e0de91f16cf79d52c6ea21a3f562 refs/remotes/origin/HEAD 
687f22d54b89e0de91f16cf79d52c6ea21a3f562 refs/remotes/origin/master 


>git log 
commit f85d2aa0900fb356d8d120f454ff2362d7475edb 
Author: tim <[email protected]> 
Date: Fri Feb 3 23:50:43 2017 -0500 

    my work 

commit 687f22d54b89e0de91f16cf79d52c6ea21a3f562 
Author: Kevin <[email protected]> 
Date: Thu Jan 19 12:26:26 2017 -0500 

    Added gitignore 
+0

あなたは 'my-branch'にコミットしていますか? 'git log'出力? –

+0

'git log'の出力については、私の追加を参照してください。私が私の支店にコミットしているかどうかはどうすればわかりますか? – Tim

答えて

1

このお試しください:デフォルトでは

$ git push origin HEAD:my-branch 
    Or, 
    $ git push -u origin my-branch 

git push origin HEAD:my-branch push the current branch to the remote ref matching my-branch in the origin repository. This form is convenient to push the current branch without thinking about its local name .

git push origin my-branch find a ref that matches my-branch in the source repository (most likely, it would find refs/heads/my-branch), and update the same ref (e.g. refs/heads/my-branch) in origin repository with it. If my-branch did not exist remotely, it would be created.

+0

ありがとうございます。何が私の問題であり、あなたが書いたコマンドが何をするのか説明できますか? – Tim

+0

ありがとうございます。 'git push -u origin my-branch'はなぜうまくいくのですか? 'git push origin HEAD:my-branch'は同じエラーで動かないのですか? – Tim

+0

ここで、 'local/my-branch'はリモートトラッキングブランチを見つけることができません("エラー:src refspec my-branch does not any'')。したがって、 '-u = --set-upstream'フラグを" git push "とすると、新しく作成されたリモートブランチ(' my-branch')を追跡するようにgitに指示します。 –

2

push policy is simple (since Git 2.0)を。
これはGitがローカルの名前を持つ名前のリモートブランチにプッシュしようとしていることを意味します。

その名前のリモートブランチがない場合は、リモートブランチを作成してプッシュすることを明示的に指定する必要があります。
参照git push -u origin my-branchを追加することで、 "Why do I need to explicitly push a new branch?"

your local first push has no idea:

  • where to push
  • what to push (since it cannot find any upstream branch being either recorded as a remote tracking branch, and/or having the same name)

、あなたのローカルブランチリモート(branch.<name>.remote)と宛先(origin/mybranchbranch.<name>.merge)に関連付けます

次のプッシュは単純git pushになります。

関連する問題