git如何将其他分支推送到远程/起源? [英] How git push other branch to remote/origin?

查看:128
本文介绍了git如何将其他分支推送到远程/起源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的.git/config:

My .git/config:

[remote "origin"]
    url = git@github.com:nfpyfzyf/test.git
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
    remote = origin
    merge = refs/heads/master

我的本​​地分支机构:

My local branches:

                     HEAD
                     |
                 F---G  feature**current branch
                /
       C---D---E develop
      /          
 A---B  master

我现在在功能分支中,想推送到远程.当前命令是什么,它是git push origin feature吗?如果我git push会发生什么?

I'm now in feature branch, and want to push to remote. What is the current command, is itgit push origin feature? What will happen if I do git push?

推荐答案

要推送特定分支,请运行git push <remote> <branch>.在您的情况下,您唯一定义的遥控器是origin,并且您想推送feature分支,这样就可以

To push a specific branch, run git push <remote> <branch>. In your case, your only defined remote is origin, and you want to push your feature branch, so that makes

$ git push origin feature

示例"部分c1>文档描述了如果在没有其他参数的情况下运行git push会发生什么情况.

The "Examples" section of the git push documentation describes what happens if you run git push with no other arguments.

git push

git push <remote>相似,在其中是当前分支的远程服务器(或origin,如果当前分支未配置任何远程服务器).

Works like git push <remote>, where is the current branch’s remote (or origin, if no remote is configured for the current branch).

鉴于您问题中的配置,您的feature分支没有配置远程,因此上述调用等效于下一个示例.

Given the configuration in your question, your feature branch does not have a remote configured, so the above invocation is equivalent to the next example.

git push origin

无需其他配置,其作用类似于git push origin :

Without additional configuration, works like git push origin :

在菊花链之后,我们看到这等效于

Following the daisy chain, we see that this is equivalent to

git push origin :

将匹配"分支推至原点.请参阅上面的 OPTIONS 部分,描述匹配".分支.

Push "matching" branches to origin. See in the OPTIONS section above for a description of "matching" branches.

匹配分支的规则是

特殊的refspec :(或+:允许进行非快进更新)指示git推送匹配"分支:对于本地存在的每个分支,如果远端已经存在相同名称的分支.如果未找到显式的refspec(在相应远程文件的命令行或任何Push行中均未找到,请参见下文)且未设置push.default配置变量,则这是默认操作模式.

The special refspec : (or +: to allow non-fast-forward updates) directs git to push "matching" branches: for every branch that exists on the local side, the remote side is updated if a branch of the same name already exists on the remote side. This is the default operation mode if no explicit refspec is found (that is neither on the command line nor in any Push line of the corresponding remotes file—see below) and no push.default configuration variable is set.

在您的情况下,唯一匹配的分支是master,因此git push将推动该分支并退出.

In your case, the only matching branch is master, so git push will push that branch and exit.

这篇关于git如何将其他分支推送到远程/起源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆