gpt4 book ai didi

git - 推送当前与推送上游(跟踪)

转载 作者:IT王子 更新时间:2023-10-29 01:01:12 26 4
gpt4 key购买 nike

我已经阅读了关于 push 命令的 git man,但我仍然不明白 currentupstreampush 中设置的确切区别.默认

我希望我们的团队只进行推送,并且只推送他们当前正在处理的分支上的更改。据我了解,这个分支是在我执行 git branch 时标有 *(星号)的分支。

感谢您的帮助。

最佳答案

问题是你在 push 什么,以及到哪里:

  • 当前:

    • what”只是你当前的分支(没有其他分支),
    • 到哪里”是 upstream repo 中的同名分支(如果不存在则创建) .
  • 上游:

作为explained here , Git2.0 会另外为push.default引入一个新的默认值:simple

simple 类似于 upstream,但 upstream 也必须同名或推送会失败。


仅推送一个分支(模式为“simple”、“current”或“upstream”)可避免 the scenario推送所有匹配分支的位置(模式“匹配”,这是很长一段时间的默认设置),即使您的某些分支可能尚未准备好推送。

(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.

两者(currentupstream)之间的区别在于pull(从远程 pull 什么到你的分支?) :

  • 推送“current”并不意味着您当前的分支 Bremote/B 有它的上游分支。< br/>即:branch.B.merge 未设置,当您推送“current”分支时。
    即:当 pull 到 B 时,git 不知道要 pull 到哪个分支。

  • pushing "upstream"意味着你当前的分支 Bremote/B 有它的上游分支。
    即:branch.B.merge 已设置,当您推送“upstream”分支时。
    即:当 pull 到 B 时,git 知道要 pull 哪个分支(以及哪个远程仓库:branch.B.remote)

关于git - 推送当前与推送上游(跟踪),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13751319/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com