提交本地项目到github中

9 篇文章 0 订阅
  1. 现在Github上新建一个仓库
  2. 在终端中cd进入要提交的项目
  3. 命令 touch README.md 创建说明文件
  4. git init 初始化本地仓库
  5. git add . 添加所有文件,效果等同于git add -A
  6. git commit -m '说明' 将文件提交到本地仓库
  7. 开始连接远程仓库,需要先复制好远程仓库的地址
  8. git remote add origin '仓库地址' 这里是连接到远程仓库,还没提交呢
  9.  git push -u origin master 把本地的文件通过-u(upStream,上传流) 推送到别名为origin的仓库中的master上
  10. 这时可能会报错,提示
    $ git push -u origin master
    The authenticity of host 'github.com (192.30.252.122)' can't be established.
    RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
    Are you sure you want to continue connecting (yes/no)? yes
    Warning: Permanently added 'github.com,192.30.252.122' (RSA) to the list of known hosts.
    To git@github.com:gaissiai/learngit.git
     ! [rejected]        master -> master (fetch first)
    error: failed to push some refs to 'git@github.com:gaissiai/learngit.git'
    hint: Updates were rejected because the remote contains work that you do
    hint: not have locally. This is usually caused by another repository pushing
    hint: to the same ref. You may want to first integrate the remote changes
    hint: (e.g., 'git pull ...') before pushing again.
    hint: See the 'Note about fast-forwards' in 'git push --help' for details.
  11.  是说远程库中的版本比本地的更新,建议你先pull一次.但因为这是我全新建立的一个仓库,所以我决定强制覆盖远程分支,使用了命令 git push origin master -f
  12. 这里就结束了创建一个仓库的流程
  13. 以后的修改,大家默认都是如下
    1. git pull 默认拉取的是master分支的代码
    2. git add .
    3. git commit -m '再次修改的说明'
    4. git push 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值