Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Github上本地查看巧克力叉中新创建的分支,并随后推送到该分支?_Git_Github_Git Branch_Chocolatey - Fatal编程技术网

如何在Github上本地查看巧克力叉中新创建的分支,并随后推送到该分支?

如何在Github上本地查看巧克力叉中新创建的分支,并随后推送到该分支?,git,github,git-branch,chocolatey,Git,Github,Git Branch,Chocolatey,摘要 Github Chocolate存储库已作为Chocolate-1转移到自己的Github帐户 已创建一个新的分支installchockelyservice InstallChocolate服务已取消 推送安装ChocolatesService分支在推送到主服务时失败 git分支表示只识别主节点 冗长 在巧克力叉中创建的额外分支 除主分支以外的其他分支 推送安装巧克力服务分支失败 推陈出新 只有主分支被识别 此命令 git branch * master 不显示新分支,因为它尚

摘要

  • Github Chocolate存储库已作为Chocolate-1转移到自己的Github帐户
  • 已创建一个新的分支
    installchockelyservice
  • InstallChocolate服务已取消
  • 推送安装ChocolatesService分支在推送到主服务时失败
  • git分支
    表示只识别主节点

冗长

在巧克力叉中创建的额外分支

除主分支以外的其他分支

推送安装巧克力服务分支失败

推陈出新

只有主分支被识别

此命令

git branch
* master
不显示新分支,因为它尚未作为本地分支存在,仅作为远程跟踪分支存在。如果您传递
--remotes
/
-r
--all
/
-a
选项,您将能够看到它

git branch -a
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/installchocolateyservice 
  remotes/origin/master
从远程分支创建本地分支 如果您想创建分支的本地版本,正确的方法是先使用
git-fetch
然后签出,而不是
git-pull
,因为
git-pull
是一种先提取,然后合并到当前分支中的方法

因此,正确的命令顺序是

git fetch origin
git checkout -b installchocolateyservice origin/installchocolateyservice 
请注意,如果您签出一个不存在的本地分支
X
,并且有一个名为
origin/X
的远程跟踪分支,则将从
origin/X
创建一个新的本地分支
X
,并设置为默认跟踪它。因此,换句话说,您也可以不使用上述命令

git fetch origin
git checkout installchocolateyservice
现在您有了一个合适的本地分支,您应该能够推送到远程分支:

git推原点头
#或
git推送源站安装巧克力服务

删除此问题是否有原因?我正要回答它。
git branch
* master
git branch -a
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/installchocolateyservice 
  remotes/origin/master
git fetch origin
git checkout -b installchocolateyservice origin/installchocolateyservice 
git fetch origin
git checkout installchocolateyservice