【问题标题】:Git pulls a push.default warningGit 拉出 push.default 警告
【发布时间】:2014-11-30 17:39:16
【问题描述】:

当我将一个 git commit 推送到我的远程仓库时,出现了这个警告:

clyde-browns-computer-2:bloccit clydiscope$ git commit -m 'Installed gem faker and generated seed    data'
[seed-data fabb6ea] Installed gem faker and generated seed data
 3 files changed, 26 insertions(+), 7 deletions(-)
clyde-browns-computer-2:bloccit clydiscope$ git checkout master
Switched to branch 'master'
Your branch is up-to-date with 'origin/master'.
clyde-browns-computer-2:bloccit clydiscope$ git merge seed-data
Updating 1811f8b..fabb6ea
Fast-forward
Gemfile      |  1 +
Gemfile.lock |  3 +++
db/seeds.rb  | 29 ++++++++++++++++++++++-------
3 files changed, 26 insertions(+), 7 deletions(-)
clyde-browns-computer-2:bloccit clydiscope$ git branch -d seed-data
Deleted branch seed-data (was fabb6ea).
clyde-browns-computer-2:bloccit clydiscope$ git push

warning: push.default is unset; its implicit value has changed in

       Git 2.0 from 'matching' to 'simple'. To squelch this message
       and maintain the traditional behavior, use:

 \git config --global push.default matching

To squelch this message and adopt the new behavior now, use:

git config --global push.default simple

When push.default is set to 'matching', git will push local branches
to the remote branches that already exist with the same name.

Since Git 2.0, Git defaults to the more conservative 'simple'
behavior, which only pushes the current branch to the corresponding
remote branch that 'git pull' uses to update the current branch.

我切换到默认匹配只是为了解决问题,但我想知道是否有人可以详细说明这究竟意味着什么,以及这种事情是如何发生的。我从 Git 2.0 开始,这对我有什么影响?

【问题讨论】:

    标签: git warnings push default


    【解决方案1】:

    表示默认情况下,Git 只推送当前分支,并且仅当该远程中存在同名远程分支时。

    这就是为什么在默认模式下the first push must be an explicit one

    git push -u origin master
    

    在你的例子中,master 已经有一个上游分支,所以git push 就足够了。

    但由于未明确设置推送策略,警告会提醒您,默认情况下,仅推送当前分支。
    在“Why is pushing to matching the default in Git?”查看更多信息

    【讨论】:

    • 或者我认为你可以指定git push --set-upstream origin master
    • @geotheory 是的,这就是我的意思:我已经修正了答案中的错字。 git push --set-upstream origin mastergit push -u origin master 一样,和我在stackoverflow.com/a/17096880/6309 中提到的一样。
    猜你喜欢
    • 2013-11-12
    • 2012-08-06
    • 2013-10-30
    • 1970-01-01
    • 2012-11-29
    • 2021-08-10
    • 2011-12-21
    • 1970-01-01
    • 2023-04-11
    相关资源
    最近更新 更多