GIT:无法推送(奇怪的配置问题) [英] GIT: Can't Push (Strange Config Issue)
问题描述
尝试从任何存储库推送时遇到以下错误:
错误:push.default的格式错误:简单的
错误:必须是无,匹配,跟踪或当前值之一。
fatal:/ home / leng / .gitconfig中的配置文件第8行
致命:无法从远程存储库读取。
这很奇怪,因为我肯定有支持简单推送行为的版本。
git --version
的输出是 git version 1.8.3.2
。
$ b $ 〜/ .gitconfig
的内容:
[user]
name =我的名字
email = MyEmail@website.com
[color]
ui = true
[push]
default = simple
这是令人毛骨悚然的地方。如果我将行为更改为匹配
(或者转换为 nothing> / code>,
跟踪
或当前
),然后尝试推送,我得到相同的确切错误信息。这怎么可能?以某种方式缓存配置?我甚至尝试重新启动。我甚至尝试从系统中彻底清除GIT(并删除〜/ .gitconfig
),然后重新安装。
如果我完全从.gitconfig文件中删除 [push]
部分(或者如果我完全删除文件),然后尝试推送,那么我得到:从'匹配'到'简单'的Git 2.0。要压制此消息
并在默认更改后维护当前行为,请使用:
git config --global push.default匹配
若要压制此消息并现在采用新的行为,使用:
git config --global push.default简单
请参阅'git help config'并搜索'push.default'以获取更多信息。
(简单模式在Git 1.7.11中引入)如果您有时使用旧版本的Git,请使用类似模式
'current'而不是'simple'
错误:push.default的格式错误:简单的
错误:必须是无,匹配,跟踪或当前值之一。
fatal:/ home / leng / .gitconfig中的配置文件第8行
致命:无法从远程存储库读取。
...所以它似乎是 确认我没有'我选择了推动行为,但是之后又说我选择了一个不受支持的行为。这里究竟发生了什么?
我甚至在完全删除〜/ .gitconfig
时发生错误。
谢谢!
$任何人都可以帮助我解决这个巫术问题吗? b $ b
编辑:
这是一个 .git / config
文件请求:
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remoteorigin]
url = ssh:// {my remote repo}
fetch = + refs / heads / *:refs / remotes /原产地/ *
[分支主]
远程=原产地
合并=参考/头/主
好的,我修正了它,但是方法是绝对的巫术。
我试图通过清除GIT,删除配置文件,重新安装GIT,然后创建本地裸存储库,然后克隆它,然后试图从那里推。非常像这样:
$ b $ pre $ sudo apt-get purge git-core
rm -f〜/ .gitconfig
sudo apt-get install git-core
cd / git
mkdir foo
cd foo
git init --bare
cd / var / www
git clone / git / foo
cd foo
touch blah.txt
git add -A
git config --global user.nameName
git config --global user.emailuser@email.com
git commit -mBlah
git push
...同样确切的错误信息,在那里没有改变。 (还是一些严重的巫术)。然后,我删除了一个没有本地来源的储存库(它通过SSH连接到它的原点)并克隆了删除它之后重新创建一个仓库(使用新的 git clone ssh:// ...
命令)。
I从$ clone命令中得到一个错误:
remote:push.default的格式不正确:简单
remote:必须是没有什么,匹配,跟踪或当前。
啊哈! 表示远程
而不是错误
。所以远程不支持这种行为。 (这并不能解释为什么错误仍然存在于只有本地存储库的本地存储库中,然而。)然后,我然后通过SSH连接到远程服务器,然后更新了那里的git-core到最新版本,重新尝试从我的本地机器克隆版本库,并且工作。
现在,我终于可以 git push
。疯狂地,这也解决了它,所以我可以从完全本地 / var 添加 / www / foo
到也完全是本地的 / git / foo
(本地原始裸仓库)。 SSH到这个远程服务器并以某种方式更新 - WITCHCRAFT - 修复了我本地机器的错误。
关于完全不同的机器的GIT版本......超越了我。多么彻底,完全疯狂。
I'm on a fresh install of Linux Mint.
I'm getting the following error when trying to push from any repository:
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/leng/.gitconfig
fatal: Could not read from remote repository.
This is very odd, because I definitely have a version that supports the simple push behavior.
The output of git --version
is git version 1.8.3.2
.
The contents of ~/.gitconfig
:
[user]
name = My Name
email = MyEmail@website.com
[color]
ui = true
[push]
default = simple
Here's where it gets creepy.
If I change the behavior to matching
(or to nothing
, tracking
, or current
, for that matter), then attempt to push, I get the same exact error message. How is that possible? Is it caching the config somehow? I've even tried rebooting. I've even tried purging GIT completely from the system (and deleting ~/.gitconfig
) then reinstalling it.
If I delete the [push]
section completely from the .gitconfig file (or if I delete the file entirely), then try to push, then I get this:
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)
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/leng/.gitconfig
fatal: Could not read from remote repository.
...so it appears to be both acknowledging that I haven't chosen a pushing behavior, but then also saying that I've chosen an unsupported behavior. What on earth is going on here?
I even get the error if I delete ~/.gitconfig
completely.
Can anyone help me out with this witchcraft?
Thanks!
EDIT:
Here is a .git/config
file requested:
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = ssh://{my remote repo}
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
Okay, so I fixed it, but the method is absolute witchcraft.
I tried to isolate the problem by purging GIT, deleting the config file, reinstalling GIT, then creating a local bare repository, then cloning it, then attempting to push from there. Pretty much like this:
sudo apt-get purge git-core
rm -f ~/.gitconfig
sudo apt-get install git-core
cd /git
mkdir foo
cd foo
git init --bare
cd /var/www
git clone /git/foo
cd foo
touch blah.txt
git add -A
git config --global user.name "Name"
git config --global user.email "user@email.com"
git commit -m "Blah"
git push
...same exact error message, no change there. (Still some serious witchcraft.)
Then, I deleted one of my repositories that doesn't have a local origin (it connects to its origin via SSH) and cloned the repository anew after deleting it (with a fresh git clone ssh://...
command).
I got an error from the clone command:
remote: Malformed value for push.default: simple
remote: Must be one of nothing, matching, tracking or current.
Ah ha! Now it says remote
instead of error
. So the remote doesn't support this behavior. (That doesn't explain why the error persists on local-only repositories with local origins, then, though.)
So I then SSH'ed into the remote server and updated the git-core there to the latest version, re-attempted to clone the repository from my local machine, and it worked.
Now, I can finally git push
. Insanely, this also fixed it so I can git push
from the entirely local /var/www/foo
to the also entirely local /git/foo
(the local origin bare repository). SSH'ing into this remote server and updating it somehow - WITCHCRAFT - fixed my local machine's error.
Why on earth the entirely local repos care about an entirely different machine's GIT version is... beyond me. How utterly, utterly insane.
这篇关于GIT:无法推送(奇怪的配置问题)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!