我从主分支创建了一个特性分支,并向我的分支添加并提交了一些更改。
现在我想将我的工作推送到远程存储库,但是它失败了。我能做些什么来解决这个问题?谢谢。
当运行git push命令时,它没有询问我的密码。正常吗?
附注:我正在使用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 <tim@xxx.com>
Date: Fri Feb 3 23:50:43 2017 -0500
my work
commit 687f22d54b89e0de91f16cf79d52c6ea21a3f562
Author: Kevin <kevin@xxx.com>
Date: Thu Jan 19 12:26:26 2017 -0500
Added gitignore发布于 2017-02-04 05:29:07
默认情况下,push policy is simple (since Git 2.0)。
这意味着Git试图推送到以本地分支命名的远程分支。
如果该名称没有任何远程分支,则需要显式声明要创建和推送所述远程分支。
见"Why do I need to explicitly push a new branch?“
你在当地的第一次尝试完全不知道:
通过添加git push -u origin my-branch,您将将远程(branch..remote)和目标(origin/mybranch:branch..merge)关联到本地分支
下一个推动将是一个简单的git push。
发布于 2017-02-04 05:13:03
试试这个:
$ git push origin HEAD:my-branch
Or,
$ git push -u origin my-branch git推送原点头:我的分支将当前分支推送到与原始存储库中的my-分支匹配的远程引用。此表单便于推送
current branch without thinking about its local name。
Vs
git推原点我的分支找到一个与源存储库中我的分支匹配的引用(很可能,它会找到ref /head/my-),并在原始存储库中更新相同的参考文献(例如,参考/头/我-分支)。如果我的分支不存在远程,它将被创建。
https://stackoverflow.com/questions/42036692
复制相似问题