gpt4 book ai didi

git - 如果我推送一个非跟踪分支会发生什么?

转载 作者:太空狗 更新时间:2023-10-29 13:40:27 26 4
gpt4 key购买 nike

考虑以下流程:

1) git checkout -b newbranch

2) 做一些提交....

3)

git push

观察

  • newbranch 没有跟踪任何远程
  • 在 bitbucket 上,创建了一个新分支:'newbranch'

为什么我可以从这个分支推 pull ?我刚刚读了http://git-scm.com/book/ch3-5.html ,据我所知,这应该行不通。

因为我可以使用“newbranch”与其他人协作、 merge 等。

基本上我看不出跟踪分支和非跟踪分支之间的区别。这可能是因为我只在差异无关紧要的特殊情况下使用 git?

评论:我确实了解跟踪以及如何设置它。问题是我不明白为什么非跟踪设置会这样工作。我也意识到我已经像这样使用 git 一段时间了

根据评论中的要求:

$ git config -l
user.email=********$
user.name=*********
push.default=current
color.ui=true
core.editor=vim
credential.helper=cache --timeout=3600
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.url=********
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master

--

最佳答案

这与您的 git 配置中的 push.default 的值有关。

来自 git-config

current - push the current branch to update a branch with the same name on the receiving end. Works in both central and non-central workflows.

这意味着 git 只是在服务器上查找具有匹配名称的分支。如果将此值更改为 upstream(或 simple),您将无法推送到未跟踪的分支,而 current匹配 将允许您推送到未跟踪的分支。

关于git - 如果我推送一个非跟踪分支会发生什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31809536/

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