社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  Git

将现有项目添加到Github

Big Daddy • 6 年前 • 690 次点击  

我有一个现有的项目需要添加到 GitHub . 我已经创建了一个本地回购,需要将其推到 新的 遥控器 github . 我公司使用 github 对于源代码管理,这是一个“私有”回购吗?不管怎样,我遵循了概述的步骤 here 并获取“未找到存储库”。我错过了什么?这不是我的经验。

git remote add origin https://myGitHubUrl/projectName ----COOL
git remote -v ----COOL
    *origin https://myGitHubUrl/projectName (fetch)*
    *origin https://myGitHubUrl/projectName (push)*
git push origin master ----NOT COOL
    *remote: Repository not found.*

编辑 我错过了第一步说:

在GitHub上创建新的存储库。为了避免错误,不要用自述文件、许可证或gitignore文件初始化新的存储库。你可以 将项目推送到GitHub后添加这些文件。

它现在起作用了。始终阅读文档!!

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/38009
文章 [ 2 ]  |  最新文章 6 年前
Nisarg
Reply   •   1 楼
Nisarg    7 年前

1)如果您试图通过https将本地repo连接到远程。如果是这种情况,那么以下命令应该为您解决该问题:

$ git remote -v
origin  https://github.com/private-repo.git (fetch)
origin  https://github.com/private-repo.git (push)
$ git remote rm origin
$ git remote add origin git@github.com:private-repo.git
$ git remote -v
origin  git@github.com:private-repo.git (fetch)
origin  git@github.com:private-repo.git (push)

2)移除远程原点

git remote rm origin

重新添加源站,但使用您的用户名和pwd,在此pvt repo上具有写入权限

git remote add origin  https://USERNAME:PASSWORD@github.com/username/reponame.git

3)您已经配置了ssh密钥

#check current github account
ssh -T git@github.com

#ensure the correct ssh key used with github
ssh-agent -s
ssh-add ~/.ssh/YOUR-GITHUB-KEY

#re-add the origin
git remote add origin git@github.com:YOUR-USER/YOUR-REPO.GIT
git push -u origin master

4)您可能需要尝试在repo url中包含我的用户名和密码来解决它:

git clone https://myusername:mypassword@github.com/path_to/myRepo.git

注: 这个详细的步骤可能会帮助您,并且正在考虑您没有在GitHub中创建回购。

在GitHub上创建新的存储库。为了避免错误,不要用自述文件、许可证或gitignore文件初始化新的存储库。您可以在项目被推送到GitHub之后添加这些文件。

    git init
    git add .
    git commit -m "First commit"

    # Sets the new remote
    git remote -v
    # Verifies the new remote URL
    git push origin master

如果存在Github回购,则执行以下步骤。

cd existing_repo
git remote rename origin old-origin
git remote add origin <url>
git push -u origin --all
git push -u origin --tags
gumol
Reply   •   2 楼
gumol    7 年前

首先在GitHub中创建存储库,并确保配置本地存储库时使用的URL与在GitHub中配置的URL匹配。

如果在创建存储库之后仍然存在相同的问题,请查看他们关于此问题的帮助页面: Here

请注意,帮助页面使用的是ssh而不是https。您可以继续使用HTTPS协议。只需在创建后(通过选择HTTPS作为您的协议)从存储库页面上提供的内容复制完整链接,以确保安全。