git 推送错误 : the requested URL returned error 400

标签 git github git-push

我是 Git 的新手,我正在尝试使用 Git Bash 将 Java 项目推送到 Github。

这是我做的:

  • 在 GitHub 中创建了博客存储库

  • 在 Git Bash 中

    $ cd C:/Users/Alessandro/workspace/BLOG

    $ echo "# Blog">> README.md

    $ git add –-all

    $ git commit -m "初始提交"

    $ git remote add origin https://github.com/alerossi82/Blog

    $ git push -u origin master

但是当我进行推送时,这是我得到的结果:

严重:无法访问“https://github.com/username/repository/” ': 请求的 URL 返回错误:400

我在某处读到这可能是登录问题,但我检查了 GitBash 中的配置,发现用户名和电子邮件与 GitHub 匹配。 当我提交推送时,我登录到我的 GitHub 帐户,但我没有收到来自 GitBash 的任何插入密码请求。

然后我尝试直接从 Eclipse 推送项目,但这也失败了,事实上,当我推送更改时,我收到消息: - master >> master [rejected - non-fast-forward]

我完全迷失了,我认为所有步骤都是正确的,但看起来我的本地和远程存储库不想相互交谈,我不知道为什么。

有什么帮助吗?

最佳答案

有一个类似的问题,结果是我的 .gitconfig 文件有一些问题,因为我之前运行过 git config --global url。"git@github.com: ".insteadOf "https://github.com/" 和以后的 git config --global url."https://github.com/".insteadOf "git@github.com:" 将这两行添加到我的 .gitconfig 文件中。所以我所做的就是在我的终端(Iterm) 中使用 vim 清理我的 .gitconfig 文件:

$vi $HOME/.gitconfig

然后使用 vim 编辑器从 .gitconfig 文件中删除不需要的行。希望对您有所帮助。

关于git 推送错误 : the requested URL returned error 400,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35827033/

相关文章:

git - 在 git push 上我得到错误 : error: invalid protocol: wanted 'old new ref'

git - 如何禁用netbeans 7.0 的自动.gitignore 修改?

python - 在 Github 提交中强制执行 PEP-8'ish 格式

git - 将分支推送到私有(private)仓库

git - 如何使用 Github 操作镜像 GitHub 存储库?

git - 如何在整个新 Github 存储库上创建 pull 请求

ubuntu - 在 Windows 子系统上设置 "git init"的问题

git - 将 github 存储库克隆到实时站点,但出现 : Permission denied (publickey). fatal error :远程端意外挂断

git - 如何在冲突的 Git rebase 中获取 "their"更改?

Github 单个 pull 请求更改多个存储库?