最新消息:

git config push.default matching

git admin 6062浏览 0评论

昨天学习了Git,今天就链接Github试试,操作git push命令,结果却遇到下面的提示

$ git push
warning: push.default is unset; its implicit value is changing inGit 2.0 from 'matching' to 'simple'. To squelch this messageand maintain the current behavior after the default changes, use:

  git config --global push.default matching

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

  git config --global push.default simple

See 'git help config' and search for 'push.default' for further information.(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode 'current' instead of 'simple' if you sometimes use older versions of Git)

Everything up-to-date

这个情况我没有遇到过,为了谨慎处理,于是网络之,发现如下解决办法,下面转自:偏安一隅

升级到 git 1.6.3 以后,每次 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
通常,这是很多 Linux 或者说开源社区贴心的地方,主动告诉你,“注意了,我们发布了一个新版本,有些地方和之前的不太一样,需要你自己动手改一下”。。。只是,为什么不直接给出一条简单明了的指令呢?<strong>比如:</strong>
git config push.default current

这样执行git push的时候,只会push当前的branch,如果设置为matching的话,会push所有的有改动的branch到相应的repository的ref中,相对来说安全性差了点。

另外,我还看到了一篇blog1,讲述了10个升级到1.6.3的理由,除了性能和易用性上的改进之外,又学到了几个新的命令:

  1. git diff —staged 等同于 git diff —cached
  2. git checkout – 返回之前的branch,类似bash。
  3. git log —graph 相当于一个终端版的gitk
  4. git log —oneline 精简版的log信息,只有changeset号的前7位和commit信息。

这里我设置如下:

git config --global push.default simple

如果你还想了解更多,可以运行git help config,会弹出git-config帮助页面,上面有如下介绍:

push.default

Defines the action git push should take if no refspec is given on the command line, no refspec is configured in the remote, and no refspec is implied by any of the options given on the command line. Possible values are:

  • nothing – do not push anything.
  • matching – push all branches having the same name in both ends. This is for those who prepare all the branches into a publishable shape and then push them out with a single command. It is not appropriate for pushing into a repository shared by multiple users, since locally stalled branches will attempt a non-fast forward push if other users updated the branch.
    This is currently the default, but Git 2.0 will change the default to simple.
  • upstream – push the current branch to its upstream branch. With this, git push will update the same remote ref as the one which is merged by git pull, making push and pull symmetrical. See “branch.<name>.merge” for how to configure the upstream branch.
  • simple – like upstream, but refuses to push if the upstream branch’s name is different from the local one. This is the safest option and is well-suited for beginners. It will become the default in Git 2.0.
  • current – push the current branch to a branch of the same name.

The simple, current and upstream modes are for those who want to push out a single branch after finishing work, even when the other branches are not yet ready to be pushed out. If you are working with other people to push into the same shared repository, you would want to use one of these.

英文学得不好就不翻译了,但大体是说simple是最安全的,也非常适合初学者。simple也将是Git2.0的默认值。

希望对你有帮助哈

转载请注明:爱开源 » git config push.default matching

您必须 登录 才能发表评论!