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

首先进入需要关联到远程仓库的项目文件夹中,执行如下命令:
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上刷新下看看是否有本地提交的项目。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值