昨天简单尝试了用vue.js搭建apexcharts的动态barcharts可视化,并将储存于本地的项目传到github上,但是按照git的命令进行执行,上传不上去,一直在报错,在此整理一下自己遇到的问题。
1. 项目结果
首先展示下本地化项目的可视化结果
上传本地至github
- 在vs code中打开项目根目录,在terminal中输入
git init
- 将项目的所有文件添加到仓库中
git add .
-
去github创建自己的repo, 拿到创建的仓库的https或者ssh地址
-
git remote到github上
git remote add origin <"clone">
这里问题就来了,前三步按照git上的步骤走,然后会报错:fatal: remote origin already exists.
网上找了很多方法,有以下几种解决方案:
a. 删除远程已经存在的origin:(一般连接过其他仓的直接这段代码执行就可以成功push了)
git remote rm origin
git remote add origin <"clone">
gitpush
依旧又报错:fatal: The current branch master has no upstream branch. To push the current branch and set the remote as upstream, use git push --set-upstream origin master
按照命令继续执行
git branch --set-upstream-to master origin/master
继续报错: fatal: branch ‘origin/master’ does not exist解决方案👇
git push --set-upstream origin master
出现新的报错: fatal: refusing to merge unrelated histories,解决方案👇
git pull origin master --allow-unrelated-histories
提交代码到远程仓库:
git push --set-upstream origin master
如果出现报错 fatal: Couldn’t find remote ref master或者fatal: ‘origin’ does not appear to be a git repository以及fatal: Could not read from remote repository. 可以试着重新
git remote add origin <"clone">
最后一步,上传代码到github远程仓库
git push -u origin master