美文网首页iOS学习笔记IOS
如何上传本地项目到GitHub远程仓库中

如何上传本地项目到GitHub远程仓库中

作者: 花果山松鼠 | 来源:发表于2017-11-13 14:22 被阅读34次

    一、建立本地仓库:操作环境(终端)

    1.cd到本地项目的文件夹路径下
    2.创建git: git init
    3.git add .
    4.git commit -m '初始化想写啥写啥'
    

    二、添加远程仓库:操作环境(github上)

    1.点击添加.png
    2.创建repository.png
    3.创建完成.png

    三、建立连接:操作环境(终端)

    git remote add origin git@github.com:DaiYongTao/demo.git
    

    其中git@github.com:DaiYongTao/demo.git 是图3中选择SSH时的地址

    四、将本地仓库push到远程仓库:操作环境(终端)

    git push -u origin master // 第一次推送master分支上所有的内容
    git push origin master // 推送最新修改
    

    五、错误问题解决办法

    (很重要!!!注:在做这些步骤的前提是已经将ssh在本地创建好了。亦或者你的ssh已经过期了,你进行上面的最后一个步骤时会报错。所以需要检查ssh状态)

    如果出现以下错误:

    Permission denied (publickey).
    fatal: Could not read from remote repository.
    
    Please make sure you have the correct access rights
    and the repository exists.
    

    是因为你的ssh过期了,需要重新获取ssh,然后添加到github上去。

    相关链接:Github上如何创建ssh

    相关文章

      网友评论

        本文标题:如何上传本地项目到GitHub远程仓库中

        本文链接:https://www.haomeiwen.com/subject/fmcimxtx.html