Git无法推送到仓库。

3

我正在尝试向一个代码库推送代码,它确实存在且链接正确。我正在强制让它要求我输入用户名和密码,因为我认为出了点问题。错误信息如下:

λ git push origin master --force -v
Pushing to https://github.com/wojlive/liveandnow.git
remote: Repository not found.
fatal: repository 'https://github.com/wojlive/liveandnow.git/' not found

尝试执行 git remote rm origin 然后执行 git remote add origin https://github.com/wojlive/liveandnow.git/ - Hamza Anis
尝试克隆存储库:git clone https://github.com/wojlive/liveandnow.git - victor
λ git clone https://www.github.com/wojlive/liveandnow.git 正在克隆 'liveandnow'... 远程:仓库未找到。 致命错误:未找到仓库 'https://github.com/wojlive/liveandnow.git/' - Przemek
1
通常情况下,GitHub会因为身份验证失败而返回403错误,所以我怀疑问题出在网络上而不是凭据。然而,如果要继续检查凭据,请运行git config --list命令并回复任何credential条目(例如credential.helper),并检查~/.git-credentials $XDG_CONFIG_HOME/git/credentials文件。 - vossad01
user.name=u1358595,所以这是错误的,怎么改正呢?// 现在它给我403错误 - Przemek
显示剩余9条评论
3个回答

3
尾部斜杠错误(afaik)不能仅通过重新输入相同的源来消除。在我的情况下,我尝试了删除并重新添加远程,但未成功:
git remote remove origin  
git remote add origin https://github.com/andybywire/jekyll-foundation.git

但是当我尝试推送我的更改时,仍然收到错误提示:

fatal: unable to access 'https://github/andybywire/jekyll-foundation.git/': Could not resolve host: github

我注意到我的一些仓库在路径末尾保留了/,而其他仓库则完全省略了.git。经过进一步调查,我发现这是由于不同的git服务器配置不同导致的。

git remote -v
origin  https://github.com/andybywire/content-first-prototyping (fetch)
origin  https://github.com/andybywire/content-first-prototyping (push) 

当我从第一个仓库中移除了.git,错误完全消失了:
git remote remove origin  
git remote add origin https://github.com/andybywire/jekyll-foundation

这个存储库现在可以让我做我所期望的一切。
我不知道为什么,但是我也尝试了很多次(重新启动,代理设置,切换Wi-Fi);这就是解决方法。

2
尝试在URI末尾删除斜杠。
git remote remove origin
git remote add origin https://github.com/wojlive/liveandnow.git

仍然存在相同的问题。 - Przemek
奇怪,你能把仓库公开吗,这样我就可以尝试了吗?它似乎目前是私有的,当我访问 https://github.com/wojlive/ 时,我无法看到它。我刚刚创建了自己的测试仓库,这应该按预期工作。你正在运行哪个版本的git? - Matt Clark
最新版本,我现在将其公开。 - Przemek
你如何移除本地凭据? - Przemek
你可以尝试读取.git/config文件 - 这可能会有相关的内容。 - Matt Clark

0

这也可以工作。完全避免了斜杠。

git remote add origin git@github.com:YOUR_USERNAME/NEW_REPO.git

此命令的结果可以在git config -l中看到:

...
remote.origin.url=git@github.com:YOUR_USERNAME/NEW_REPO.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master

(如果需要),首先创建一个新的存储库:是否可能在不打开浏览器的情况下从CLI上在GitHub上创建远程存储库?

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接