Git Push问题 - 迂腐

时间:2010-02-19 08:16:21

标签: git

我的项目中有一个master分支和一个searchfeature分支。我已将searchfeature分支推送到远程存储库,到目前为止一切正常

当我今天早上在那个分支上工作时,我做了“git push”我得到了以下内容:

warning: You did not specify any refspecs to push, and the current remote
warning: has not configured any push refspecs. The default action in this
warning: case is to push all matching refspecs, that is, all branches
warning: that exist both locally and remotely will be updated.  This may
warning: not necessarily be what you want to happen.
warning: 
warning: You can specify what action you want to take in this case, and
warning: avoid seeing this message again, by configuring 'push.default' to:
warning:   'nothing'  : Do not push anything
warning:   'matching' : Push all matching branches (default)
warning:   'tracking' : Push the current branch to whatever it is tracking
warning:   'current'  : Push the current branch

所以我继续做了一个git config push.default跟踪和瞧,git push工作没问题,没有警告。

我不明白的是“当前”和“跟踪”之间的区别在于,如果你不做“跟踪它的任何事情”,那么“当前”的意义是什么 - 它会去哪里?你会使用当前而不是跟踪的场景?

此外,有什么场景会使用“什么都没有”?

1 个答案:

答案 0 :(得分:6)

Git1.6.3

  

当用户没有告诉“git push”推送什么时,它总是推送匹配的参考   对于某些人来说,这是意料之外的,并且引入了新的配置变量push.default以允许更改不同的默认行为   要宣传新功能,如果未配置此功能,则会发出重大警告,并尝试使用不带参数的git push。

因此,当前和跟踪之间的区别在于:

  • current将假设匹配的ref(具有同名的远程分支,可能不存在)
  • 跟踪将基于远程引用在与该本地分支关联的跟踪引用上使用。如果它没有跟踪任何东西,它就不会推动。但它可以跟踪具有不同名称的远程分支.a remo

注意:default nothing对于只读存储库非常有用,只能用于内容咨询,不应该在任何地方进行任何工作。

另见git push current branch SO问题。


2012年3月更新:注意:默认“匹配”政策可能很快就会改变

请参阅“Please discuss: what "git push" should do when you do not say what to push?

  

在当前设置(即 push.default=matching )中,没有参数的 git push将推送本地和远程存在的所有分支同名
  这通常适用于开发人员推送到自己的公共存储库时,但在使用共享存储库时可能会造成混淆。

     

建议将默认设置更改为“upstream,即仅推送当前分支,然后将其推送到分支git pull将从中拉出。
  另一位候选人是“current”;这会将当前分支仅推送到同名的远程分支。

     

到目前为止所讨论的内容可以在这个帖子中看到:

http://thread.gmane.org/gmane.comp.version-control.git/192547/focus=192694

  

以前的相关讨论包括:

  

要加入讨论,请将您的消息发送至:git@vger.kernel.org