bash 执行推送时出现 Git 错误 400

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18088617/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 06:09:42  来源:igfitidea点击:

Git error 400 when doing push

gitbashgithubterminal

提问by Nathan Dunn

When I do a git pushI come up with this error:

当我做一个git push我想出这个错误:

error: The requested URL returned error: 400 while accessing https://github.com/nathandunn97/SchoolAdvisor.git/info/refs?service=git-receive-packfatal: HTTP request failed

错误:请求的 URL 返回错误:400 访问 https://github.com/nathandunn97/SchoolAdvisor.git/info/refs?service=git-receive-pack致命:HTTP 请求失败

I am using Ubuntu 13.04 and my git version is 1.8.1.2.

我使用的是 Ubuntu 13.04,我的 git 版本是 1.8.1.2。

回答by wobbily_col

I has something similar to this on an internally hosted git repository (so I am not 100% sure it will fix your problem on github). "Git pull" worked fine, but "git push" gave me:

我在内部托管的 git 存储库上有类似的东西(所以我不能 100% 确定它会解决你在 github 上的问题)。“Git pull”工作正常,但“git push”给了我:

error: The requested URL returned error: 400 while accessing http://10.3.231.11/fisheye/git/myrep.git/info/refs

What worked for me was going into.git/config, and changing the url to include my username in the url:

对我有用的是进入 .git/config,并更改 url 以在 url 中包含我的用户名:

[remote "origin"]
    fetch = +refs/heads/*:refs/remotes/origin/*
    url = http://[email protected]/fisheye/git/myrep.git

It then asked for a password after the push command, then pushed the files successfully.

然后它在 push 命令后要求输入密码,然后成功推送文件。

回答by CodeWizard

When you do a push with https you might need to write your password every time. generate ssh keys for git hub

当您使用 https 进行推送时,您可能每次都需要输入密码。为 git hub 生成 ssh 密钥

https://help.github.com/articles/generating-ssh-keys

https://help.github.com/articles/generate-ssh-keys

and then update your config file to the ssh url and you should be able to push your content.

然后将您的配置文件更新到 ssh url,您应该能够推送您的内容。