在git中的远程存储库上创建一个新分支

发布于 2024-09-06 19:44:39 字数 538 浏览 4 评论 0原文

正如标题所示,我正在尝试在远程存储库上的 git 中创建一个新分支。

为此,我之前一直使用以下命令。

git push origin origin:refs/heads/rounding_issue

这通常可以正常工作,然后我可以运行

git branch -r

来确认。

然而今天早上这不起作用,我收到了以下错误消息。

error: src refspec origin does not match any.
error: failed to push some refs to '{user}@{location}:{repository}.git'

我用谷歌搜索了该消息并检查了各个网站,人们提出的唯一解释(我发现)是,也许主分支需要先推送,或者您需要先提交一些东西,我已经尝试过主机不同的事情,但每次错误消息都是相同的。

我可以很好地提交到 master 分支。

任何帮助将不胜感激。

As the title says I am trying to create a new branch in git on the remote repository.

To do this I have previously been using the following command.

git push origin origin:refs/heads/rounding_issue

Which normally just works and I can then run

git branch -r

To confirm.

This morning however this is not working and I have received the following error messages.

error: src refspec origin does not match any.
error: failed to push some refs to '{user}@{location}:{repository}.git'

I have googled the message and checked various sites and the only explanation people have been coming up with (that I have found) is that maybe the master branch needs pushed first or there are some things you need to commit first, I have tried a host of different things but each time the error message is the same.

I can commit to the master branch fine.

Any help would be greatly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

温柔少女心 2024-09-13 19:44:39

git Push origin HEAD:refs/heads/rounding_issue 有效吗?

您可以将“HEAD”更改为本地存储库中的其他提交,如“master”或“rounding_issue”(如果您本地有该分支)或直接 SHA-1 编号。

git push origin HEAD:refs/heads/rounding_issue Works?

You can change "HEAD" with some other commit in your local repository, as "master" or "rounding_issue" (if you have that branch locally) or direct SHA-1 number.

无可置疑 2024-09-13 19:44:39
git push origin rounding-issue

仅此而已

git push origin rounding-issue

only that

白芷 2024-09-13 19:44:39

如果您收到错误,表明您当前无权访问远程存储库。您可能还没有设置。当您在本地创建新分支,但忘记在远程启动它时,通常会发生这种情况。

git 远程-v
这将检查您当前的分支是否已连接到远程存储库。

如果不是,那么您必须使用此命令在远程设备上设置新分支。

git remote add origin [paste in your remotes SSH]

完成此操作后,您可以使用此命令将新分支推送到远程。

git push origin [new branch name]

希望这有帮助。

约翰

If you are getting an error that states that you currently do not have access to the remote repositories. Chances are that you probably haven't set one up yet. This often happens when you create a new branch on your local, but forget to initiate it on the Remote.

git remote -v
this will check for you if the current branch you are is connected to a remote repository.

If it isn't, then you have to set up the new branch on the remote with this command.

git remote add origin [paste in your remotes SSH]

Once you have done that then you can push the new branch to the remote by using this command.

git push origin [new branch name]

Hope this helps.

John

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文