美文网首页
github将本地项目与gitHub相关联

github将本地项目与gitHub相关联

作者: Arnoux | 来源:发表于2019-04-22 12:57 被阅读0次

    首先在项目目录下初始化本地仓库

    git init

    添加所有文件

    git add .

    提交所有文件到本地仓库

    git commit -m "备注信息"

    连接到远程仓库

    git remote add origin 你的远程仓库地址

    (建议)拉取,更新本地仓库,防止冲突

    git pull origin master

    将项目推送到远程仓库

    git push -u origin master

    如果此时提示

     ! [rejected]        master -> master (non-fast-forward)
    error: failed to push some refs to 'https://github.com/abc/abc.git'
    hint: Updates were rejected because the tip of your current branch is behind
    hint: its remote counterpart. Integrate the remote changes (e.g.
    hint: 'git pull ...') before pushing again.
    hint: See the 'Note about fast-forwards' in 'git push --help' for details.
    

    说明文件版本不是最新的,此时先更新本地文件仓库至最新再push

    两种方法

    git pull --rebase origin master

    这种方法可以自动合并一些冲突?(貌似)

    git push -f origin master

    注意!!!这种方法能保证成功但等待你的是法律的制裁项目经理的天马流星拳之锤爆你狗头!!!

    注意!!!这种方法能保证成功但等待你的是法律的制裁项目经理的天马流星拳之锤爆你狗头!!!

    注意!!!这种方法能保证成功但等待你的是法律的制裁项目经理的天马流星拳之锤爆你狗头!!!

    这种方法会让你的项目被清空然后将你当前推送的内容设为新内容,清空内容包括但不限于:之前的所有的版本时间线,此命令非常危险,慎用!

    相关文章

      网友评论

          本文标题:github将本地项目与gitHub相关联

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