git - 推动电流与推动上游(跟踪) [英] git - push current vs. push upstream (tracking)

查看:97
本文介绍了git - 推动电流与推动上游(跟踪)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读过关于push命令的git man,但我仍然不明白当前和上游之间的明显区别, .default



我希望我们的团队只会推送,并且只会改变他们当前正在处理的分支,将会被推送。
据我所知,当我做 git分支时,这个分支是标有*(星号)的那个分支。

帮助。

解决方案

问题在于您正在推送什么 / em>:


  • 当前




    • 什么只是您当前的分支(没有其他分支),

    • 上游回购



    • $ b

      • 什么也只是当前分支,

      • 到哪里是指任何分支(不一定是相同的名称)上游回购已被指定为上游分支机构为您推送的本地分行。




    正如这里解释过的,Git2.0会另外引入一个新的默认值 push.default 简单
    $ b

    简单 就像 上游 ,但上游必须具有相同的名称,否则推送将失败。






    仅推送一个分支模式简单当前上游)避免场景,其中所有匹配分支被推送(模式匹配,这是很长一段时间的默认值),即使你的一些分支可能没有准备好被推送。

     (主)> git push 
    ...
    到git@github.com:jkubicek / my_proj.git
    21b430d..dd378ca master - >掌握
    ! [被拒绝]发布 - >发布(非快速转发)
    错误:未能将某些引用推送到'git@github.com:jkubicek / my_proj.git'
    提示:更新被拒绝,因为推送的分支提示位于其后远程
    提示:对应。
    提示:如果您不打算推送该分支,则可能需要
    提示:指定分支以推送或设置'push.default'配置
    hint:variable为'current'或'上游'仅推送当前分支。






    两者之间的差异( current upstream )在 pull 中(从远程连接到你的分支)




    • 当前并不意味着您当前的分支 B 具有远程/ B 具有其上游分支。

      Ie:当您推送当前分支时,没有设置> branch.B.gege
      Ie:当拉到 B 时,git将不知道要拉什么分支。

    • 推动 upstream 表示您当前的分支 B remote / B has它的上游分支。

      Ie: branch.B.merge 设置的,当你推动 upstream 分支。

      即:拉到 B 时,git知道要拉什么分支作为哪个远程回购: branch.B.remote

    I have read the git man about push command, but I still don't understand the EXACT difference between current and upstream to be set in the push.default

    I want that our team will just do push, and only changes on the branch that they are currently working on, will be pushed. As I understand, this branch is the one that marked with * (star) when I do git branch.

    Thanks for helping out.

    解决方案

    The question is what are you pushing, and to where:

    • current:

      • "what" is only your current branch (no other branches),
      • "to where" is a branch of the same name (created if it doesn't exist) in the upstream repo.
    • upstream:

      • "what" is also only the current branch,
      • "to where" is to whatever branch (not necessarily of the same name) on the upstream repo has been assigned as an upstream branch for the local branch you are pushing.

    As explained here, Git2.0 will additionally introduce a new default for push.default: simple

    simple is like upstream, but the upstream has to have the same name as well or the push will fail.


    Pushing only one branch (with the mode "simple", "current" or "upstream") avoids the scenario where all matching branches are pushed (mode "matching", which was the default for a long time), even though some of your branches might not be ready to be pushed.

    (master)> git push
    ...
    To git@github.com:jkubicek/my_proj.git
       21b430d..dd378ca  master -> master
     ! [rejected]        release -> release (non-fast-forward)
    error: failed to push some refs to 'git@github.com:jkubicek/my_proj.git'
    hint: Updates were rejected because a pushed branch tip is behind its remote
    hint: counterpart. 
    hint: If you did not intend to push that branch, you may want to
    hint: specify branches to push or set the 'push.default' configuration
    hint: variable to 'current' or 'upstream' to push only the current branch.
    


    The difference between the two (current and upstream) is in the pull (what to pull from the remote to your branch?):

    • pushing "current" doesn't mean that your current branch B has remote/B has its upstream branch.
      Ie: branch.B.merge isn't set, when your are pushing the "current" branch.
      Ie: when pulling to B, git won't know what branch to pull.

    • pushing "upstream" means that your current branch B has remote/B has its upstream branch.
      Ie: branch.B.merge is set, when your are pushing the "upstream" branch.
      Ie: when pulling to B, git knows what branch to pull (as well as which remote repo: branch.B.remote)

    这篇关于git - 推动电流与推动上游(跟踪)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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