![](/img/trans.png)
[英]Git push over ssh fails using remote url instead of origin name - (ERROR: Repository not found)
[英]git push error: repository not found even though remote url is added
I have added repository url using git remote add origin https://github.com/**.git
If I check with git remote -v
I can able to see repo url, but still when pushing to same url,using git push origin master
我发现remote: Repository not found. fatal: repository 'https://github.com/**.git/' not found
remote: Repository not found. fatal: repository 'https://github.com/**.git/' not found
。 上面的存储库 url 仍然存在,我可以克隆但是在推送时我遇到了这个错误可能是什么原因?
我已经使用rm -rf.git
删除.git
并再次使用git init
进行了初始化,并且我能够推送代码。
请按照以下步骤避免这些问题。
在没有 GitHub CLI 的情况下将项目添加到 GitHub。
在 GitHub.com 上创建一个新的存储库。 为避免错误,请勿使用 README、许可证或忽略文件来初始化新存储库。 您可以在您的项目推送到 GitHub 后添加这些文件。
创建新存储库下拉列表。 打开 Git Bash 将当前工作目录更改为本地项目。
将本地目录初始化为 Git 存储库。
$ git init -b main
将文件添加到新的本地存储库中。 这会将它们分阶段进行第一次提交。
$ git add .
# Adds the files in the local repository and stages them for commit. To unstage a file, use 'git reset HEAD YOUR-FILE'.
提交您在本地存储库中暂存的文件。
$ git commit -m "First commit"
# Commits the tracked changes and prepares them to be pushed to a remote repository. To remove this commit and modify the file, use 'git reset --soft HEAD~1' and commit and add the file again.
在 GitHub.com 的“快速设置”页面上的存储库顶部,单击以复制远程存储库 URL。复制远程存储库 URL 字段在命令提示符下,添加 URL 作为将推送本地存储库的远程存储库。
$ git remote add origin <REMOTE_URL>
# Sets the new remote
$ git remote -v
# Verifies the new remote URL
Push the changes in your local repository to GitHub.com.
$ git push origin main
# Pushes the changes in your local repository up to the remote repository you specified as the origin
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.