"简单" vs“当前” push.default在git中用于分散的工作流程 [英] "simple" vs "current" push.default in git for decentralized workflow
问题描述
简单
和当前
选项之间的区别。 push.default
配置设置。 当前
当前分支到指定远程上的同名分支。 simple
对于当前分支的跟踪和任何未跟踪的远程都会同样做同样的事情(它在两种情况下强制使用相同的分支名称)。 b
$ b
有人可以解释我缺少的分散工作流程之间的任何重要区别吗?解析方案
p>不同之处在于,如果当前分支isn,那么使用简单
, git push
(无需传递一个refspec)将会失败'跟踪远程上游分支(即使远程存在一个同名的分支):
$ git checkout - b foo
$ p $另一方面,
切换到新分支'foo'
$ git config push.default简单
$ git push
致命:当前分支foo没有上游分支。
要推送当前分支并将远程设置为上游,请使用
git push --set-upstream origin foo
current
不关心当前分支是否跟踪上游,它只是想要推送到任何具有相同名称的分支:$ git config push.default当前
$ git push
总计0(delta 0),重用0(delta 0)
到/ Documents / GitHub / bare
* [new branch] foo-> foo
文档
a href =https://www.kernel.org/pub/software/scm/git/docs/git-config.html =noreferrer> Git配置文档:
upstream
- 将当前分支推送到其上游分支。
简单
- 与上游一样,但拒绝推送,如果上游分支的名称不同于本地的...- 。
Functionally speaking, in a decentralized workflow, I don't see the difference between
simple
andcurrent
options forpush.default
config setting.
current
will push the current branch to an identically named branch on the specified remote.simple
will effectively do the same thing as well for both the tracked and any untracked remotes for the current branch (it enforces identical branch names in both cases).Can someone explain any important differences between the two for decentralized workflows that I am missing?
解决方案The difference is that with
simple
,git push
(without passing a refspec) will fail if the current branch isn't tracking a remote upstream branch (even if a branch with the same name exists on the remote):$ git checkout -b foo Switched to a new branch 'foo' $ git config push.default simple $ git push fatal: The current branch foo has no upstream branch. To push the current branch and set the remote as upstream, use git push --set-upstream origin foo
On the other hand,
current
doesn't care about whether or not the current branch tracks an upstream, it just wants to push to any branch that has the same name:$ git config push.default current $ git push Total 0 (delta 0), reused 0 (delta 0) To /Documents/GitHub/bare * [new branch] foo-> foo
The Documentation
From the Git configuration documentation:
upstream
- push the current branch to its upstream branch...
simple
- like upstream, but refuses to push if the upstream branch’s name is different from the local one...
current
- push the current branch to a branch of the same name.
这篇关于"简单" vs“当前” push.default在git中用于分散的工作流程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!