简体   繁体   English

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

[英]Creating a new branch on the remote repository in git

As the title says I am trying to create a new branch in git on the remote repository. 正如标题所说我试图在远程存储库的git中创建一个新的分支。

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. 任何帮助将不胜感激。

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

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. 您可以使用本地存储库中的其他提交更改“HEAD”,例如“master”或“rounding_issue”(如果您在本地拥有该分支)或直接使用SHA-1号码。

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. git remote -v如果您当前的分支连接到远程存储库,这将检查您。

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 约翰

git push origin rounding-issue

只有这样

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM