使用git首次上传代码

一直以来没有去建立自己的代码库,最近发现这样不行,不算一个合格的程序员,所以最近开始吧自己以前的一些项目代码上传,一是保存代码,毕竟存在自己电脑或者云盘也不是很好的一个选择。(账号很早申请了就是没用)

首先就是安装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 ""

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值