Git pulls a push.default warning

2019-05-06 18:28发布

When I pushed a git commit to my remote depository, this warning appeared:

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.

I switched to default matching just to solve the problem, but I was wondering if anybody could elaborate on what this means exactly, and how this type of thing happens. I started on Git 2.0, so how does this apply to me?

1条回答
何必那么认真
2楼-- · 2019-05-06 18:58

It means that by default, Git pushes only the current branch, and only if a remote branch of the same name exists in that remote.

That is why, in that default mode, the first push must be an explicit one:

git push -u origin master

In your case, master already had an upstream branch, so git push was enough.

But since the push policy wasn't explicitly set, the warning reminds you that, by default, only the current branch is pushed.
See more at "Why is pushing to matching the default in Git?"

查看更多
登录 后发表回答