gpt4 book ai didi

git - 错误 : src refspec my-branch does not match any

转载 作者:太空狗 更新时间:2023-10-29 14:43:38 26 4
gpt4 key购买 nike

我从主分支创建了一个功能分支,并向我的分支添加并提交了一些更改。

现在我想把我的工作推送到远程仓库,但是失败了。我能做些什么来解决这个问题?谢谢。

当运行 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

最佳答案

默认情况下,push policy is simple (since Git 2.0) .
这意味着 Git 会尝试推送到以本地分支命名的远程分支。

如果您没有该名称的任何远程分支,则需要明确声明您要创建并推送所述远程分支。
参见“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)

通过添加 git push -u origin my-branch ,您将与本地分支关联一个远程( branch.<name>.remote )和一个目的地(origin/mybranch: branch.<name>.merge )

下一次推送将是一个简单的 git push .

关于git - 错误 : src refspec my-branch does not match any,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42036692/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com