gpt4 book ai didi

Git 推送问题 - 迂腐

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

我的项目中有一个 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 可以正常工作,没有任何警告。

我不明白的是“当前”和“跟踪”之间的区别是什么,如果您不对“正在跟踪的任何东西”执行操作,那么“当前”的意义何在 - 它会去哪里?,您会在哪些情况下使用电流而不是跟踪?

还有,什么场景会用到“nothing”?

最佳答案

Git1.6.3 :

When the user does not tell "git push" what to push, it has always pushed matching refs.
For some people it is unexpected, and a new configuration variable push.default has been introduced to allow changing a different default behavior.
To advertise the new feature, a big warning is issued if this is not configured and a git push without arguments is attempted.

所以current和tracking的区别在于:

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

注意:default nothing 对于只读存储库很有用,仅用于内容咨询,不应在任何地方完成和发布任何工作。

另见 git push current branch所以问题。


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

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

In the current setting (i.e. push.default=matching), git push without argument will push all branches that exist locally and remotely with the same name.
This is usually appropriate when a developer pushes to his own public repository, but may be confusing if not dangerous when using a shared repository.

The proposal is to change the default to 'upstream', i.e. push only the current branch, and push it to the branch git pull would pull from.
Another candidate is 'current'; this pushes only the current branch to the remote branch of the same name.

What has been discussed so far can be seen in this thread:

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

Previous relevant discussions include:

To join the discussion, send your messages to: git@vger.kernel.org

关于Git 推送问题 - 迂腐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2294870/

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