美文网首页
上传一个项目到GitHub

上传一个项目到GitHub

作者: 三月木头 | 来源:发表于2019-12-28 09:31 被阅读0次
    1. 首先在GitHub创建一个项目文件

    2. 进入本地创建项目所在文件夹Git init创建本地Git 环境

    3. Git add . 将项目加载到暂存区。

    4. Git commit -m "备注描述内容"将项目加载到本地仓库区

    5. git remote add origin https://gitee.com/MarchWood680/Block.git 关联本地库 同 远端库

    6. git push -u origin master(-u表示刚开始远程仓库没有内容,有了内容之后就不用再写了)
      如果新建远程仓库不是空的,例如你勾选了 Initialize this repository with a README。那么你通过命令 $ git push -u origin master是会报错的,如下:

    MarchWooddeMacBook-Pro:BlockTest marchwood$ git push -u origin master
    To https://gitee.com/MarchWood680/Block.git
     ! [rejected]        master -> master (fetch first)
    error: failed to push some refs to 'https://gitee.com/MarchWood680/Block.git'
    hint: Updates were rejected because the remote contains work that you do
    hint: not have locally. This is usually caused by another repository pushing
    hint: to the same ref. You may want to first integrate the remote changes
    hint: (e.g., 'git pull ...') before pushing again.
    hint: See the 'Note about fast-forwards' in 'git push --help' for details.
    MarchWooddeMacBook-Pro:BlockTest marchwood$ 
    

    这是由于你新创建的那个仓库里面的README文件不在本地仓库目录中,这时我们可以通过以下命令先将内容合并以下:

    git pull --rebase origin master
    
    1. git push origin master提交本地项目到远端库

    相关文章

      网友评论

          本文标题:上传一个项目到GitHub

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