[英]“git init” failed, what's wrong?
This issue is not same as " Bad git config file .git/config ", since it failed when using git init
.这个问题与“ Bad git config file .git/config ”不同,因为它在使用
git init
时失败了。
It seems there is nothing wrong with /home/mirror/.gitconfig: /home/mirror/.gitconfig 似乎没有问题:
[mirror@home php]$ git init
error: Malformed value for push.default: simple
error: Must be one of nothing, matching, tracking or current.
fatal: bad config file line 8 in /home/mirror/.gitconfig
This is the content of ~/.gitignore:这是 ~/.gitignore 的内容:
cat ~/.gitconfig
[alias]
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
[user]
email = xxxxxx@gmail.com
name = xxxxx
[push]
default = simple
Simple was added in git v1.7.11. Simple 是在 git v1.7.11 中添加的。 If your git version is older, this option doesn't exist.
如果您的 git 版本较旧,则此选项不存在。 Simply remove it from your
conf
and you'll be able to init
repos.只需从您的
conf
删除它,您就可以init
repos。
See Documentation查看文档
This problem keeps coming up now that git 1.8 is out.现在 git 1.8 出来了,这个问题不断出现。 Luckily the message from git is now very helpful:
幸运的是,来自 git 的消息现在非常有用:
warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and 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)
For example, emacs interface to git (vc) does not understand the argument 'simple', so you are better off using the argument 'matching' for the time being.例如,git (vc) 的 emacs 接口不理解参数“简单”,因此您最好暂时使用参数“匹配”。
Try updating config to use matching
instead of simple
for push.default
.尝试更新配置以使用
matching
而不是simple
的push.default
。
git config --global push.default matching
or要么
git config push.default matching
Note that it can be problematic identifying the issue, considering the problem is at:请注意,考虑到问题位于:
default = simple
),default = simple
), Solutions:解决方案:
git config --global push.default matching
)git config --global push.default matching
)git config --global --unset-all push.default
)git config --global --unset-all push.default
) But most importantly, starting git 2.2 (Q4 2014), the git config error line number will be accurate .但最重要的是,从 git 2.2(2014 年第四季度)开始, git config 错误行号将是准确的。
See commit b3b3f60 , by Matthieu Moy ( moy
) :请参阅Matthieu Moy (
moy
) 提交的 b3b3f60 :
config.c
: fix accuracy of line number in errors config.c
: 修复错误中行号的准确性If a callback returns a negative value to
git_config*()
family, they calldie()
while printing the line number and the file name.如果回调向
git_config*()
系列返回负值,它们die()
在打印行号和文件名时调用die()
。
Currently the printed line number is off by one, thus printing the wrong line number.当前打印的行号差一,因此打印了错误的行号。
Make
linenr
point to the line we just parsed during the call to callback to get accurate line number in error messages.使
linenr
指向我们在调用回调期间刚刚解析的行,以获取错误消息中的准确行号。
如果您使用早于 1.7.11 的 Git 版本,请使用类似模式current
而不是simple
。
git config --global push.default current
Since I came across this when searching for the Malformed value for push.default: simple
error I got when pushing/pulling, I figured other people may as well.由于我在搜索
Malformed value for push.default: simple
的Malformed value for push.default: simple
时遇到了这个Malformed value for push.default: simple
推/拉时Malformed value for push.default: simple
错误,我想其他人也可能Malformed value for push.default: simple
。
Here's a related question that provides more information for the passer-by (see my answer at the end for more links, too): GIT: Can't Push (Strange Config Issue)这是一个相关问题,它为路人提供了更多信息(有关更多链接,请参阅我最后的回答): GIT:无法推送(奇怪的配置问题)
Note in particular that this error seems to be caused by having an older version of Git somewhere.请特别注意,此错误似乎是由于某处使用旧版本的 Git 引起的。 The best solution is to update to the latest version of Git on all machines.
最好的解决方案是在所有机器上更新到最新版本的 Git。
If this is not possible for you, simply run the following commands (as mentioned by @morefromalan):如果这对您来说是不可能的,只需运行以下命令(如@morefromalan 所述):
git config --global push.default matching
or要么
git config --global push.default upstream
to get rid of the error.摆脱错误。 This changes the default behavior of
push
operations as described HERE .这改变的默认行为
push
所描述的操作这里。 You may have to to this for pull
as well as push
, but it seems to be working for me just having changed the default push
behavior to upstream
.对于
pull
和push
,您可能必须这样做,但它似乎对我有用,只是将默认push
行为更改为upstream
。
Good luck!祝你好运!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.