您的位置:首页 > Web前端 > Vue.js

将本地vue-cli3创建的项目关联到github远程仓库

2019-06-19 13:24 337 查看
版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。 本文链接:https://blog.csdn.net/weixin_45266779/article/details/92828742

首先进入需要关联到远程仓库的项目文件夹中,执行如下命令:
1、

git init

git init 初始化项目,如果是vue-cli3生成的项目,则跳过此步骤。

2、

git remote add origin < remote-repository-address >

将本地的项目与远程仓库关联起来,remote-repository-address为远程仓库地址,可以去github去获取,然后执行
git remote -v
查看是否关联成功。

3、

git add .

将项目提交到暂存区。

4、

git commit -m
“提交描述”
将项目提交到本地版本库。

5、

git push origin master

将项目推送到远程仓库。

ps:问题来啦,当在执行第5步的时候可能会不成功,报如下错误

! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/#####/vue-project.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.

大概意思就是更新被拒绝提示你应该

git pull
一下,当执行
git pull origin master
时,报错又来啦
fatal: refusing to merge unrelated histories
,意思是拒绝合并不相关的历史。查阅了下资料,可以在git pull命令后加上–allow-unrelated-histories选项,问题就迎刃而解了,
git pull origin master --allow-unrelated-histories

然后就可以愉快的
git push origin master
了,最后去github上刷新下看看是否有本地提交的项目。

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐