一直以来没有去建立自己的代码库,最近发现这样不行,不算一个合格的程序员,所以最近开始吧自己以前的一些项目代码上传,一是保存代码,毕竟存在自己电脑或者云盘也不是很好的一个选择。(账号很早申请了就是没用)
首先就是安装git了,这个百度就行。因为以前一直没用过git所以难免会有错,
第一步:在码云上新建项目,不详细描述
第二步:git init 在本地新建一个.git文件夹(就是所说的建立本地git仓库)
第三部:git remote add origin git@gitee.com:heqiang917/hnhtyy-wx-web.git,关键远程项目地址
可以先用git remote -v
查看远程库信息:
第四部:$ git pull origin master,这里是将远程仓库的README文件pull下来,因为在码云上新建项目就已经生成README文件了,就不用本地去touch README和git add README了。
第六步:git commit -m 'first commit' ,进行注释
第七部:$ git push origin master 将项目上传到远程仓库
犯的错
Git常见错误与操作:error: src refspec master does not match any解决办法
http://blog.csdn.net/s164828378/article/details/52425208
fatal: Could not read from remote repository.的解决办法
http://blog.csdn.net/huahua78/article/details/52330792
git:fatal the current branch master has no upstream branch
http://blog.csdn.net/qqb123456/article/details/25319659
error: failed to push some refs to 'git@github.com:michaelliao/learngit.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
https://www.cnblogs.com/daemon369/p/3204646.html
1.使用强制push的方法:
$ git push -u origin master -f
git commit -m ""的时候会出现这个问题
是因为下面的文件没加入git,使用git status 查看那些文件,然后git add 文件加到git,再执行给 git commit -m ""