“简单”vs“当前”push.default在分散工作stream的git中

从function上讲,在分散的工作stream程中,我看不到push.defaultconfiguration设置的simplecurrent选项之间的区别。

current会将当前分支推送到指定远程的同名分支。 对于当前分支的跟踪和任何未跟踪的远程(在两种情况下它强制执行相同的分支名称), simple也会有效地做同样的事情。

有人可以解释我所缺less的分散工作stream程之间的重要区别吗?

不同之处在于,如果当前分支没有跟踪远程上游分支(即使远程存在同名的分支), simplegit push (无需传递一个refspec)将会失败:

 $ 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 

另一方面, current并不关心当前分支是否跟踪上游,而只是想推送到同名的分支:

 $ git config push.default current $ git push Total 0 (delta 0), reused 0 (delta 0) To /Documents/GitHub/bare * [new branch] foo-> foo 

文档

从Gitconfiguration文档 :

  • upstream – 推动当前分行上游分行…

  • simple – 像上游,但拒绝推动,如果上游分支的名字是不同于本地的… …

  • current – 将当前分支推送到同名分支。

不同之处在于,如果simple的追踪分支具有相同的名称,则simple推送到它的追踪分支,而不pipe任何追踪分支, current将推送到具有相同名称的分支:

 $ git branch -vvv master 58d9fdc [origin/master: ahead 1] t1 bobo * new 37132d3 [origin/save: ahead 1] t1 bibi # <- tracking branch 'save' $ git -c push.default=current push # <- set `push.default=current` Counting objects: 3, done. Writing objects: 100% (3/3), 234 bytes | 0 bytes/s, done. Total 3 (delta 0), reused 0 (delta 0) To /home/jthill/sandbox/20/t1 * [new branch] new -> new # <- and push creates `new`