warning: push.default is unset;

git push warning questions

This warning was introduced in Git 1.7.11 along with the simple style of pushing. The issue is that the current default, matching, can result in inexperienced users force pushing when some branches are behind their remote equivalent because the branches simply aren't up-to-date. The end result is that they end up rewinding the branch and potentially losing their work or someone else's. The simplemode was introduced as a new push.default behavior and will become the default in Git 2.0 (which should hopefully be out sometime early next year).

The new simple behavior is a lot like the upstream setting: it only pushes the current branch that you're currently on, if it has a remote branch that it's tracking. It adds one extra criteria: the remote branch must have the same name as the local one.

As you discovered, the way to get rid of the message is to set push.default. To get the new behavior, use:

git config --global push.default simple

To get Git's default behavior but without the warning message, use:

git config --global push.default matching

I'd really advise against using matching though. In general, most people really want the new simplebehavior, or upstream.

原文地址:https://www.cnblogs.com/chucklu/p/4754533.html