首页 > 其他 > 详细

git本地与github仓库文件同步

时间:2020-04-05 23:22:33      阅读:109      评论:0      收藏:0      [点我收藏+]

本地准备工作

  • 下载、安装git
  • 绑定用户
$ git config --global user.name "Your Name"
$ git config --global user.email "email@example.com"
  • 配置 SSH
$ ssh-keygen -t rsa -C "youremail@example.com"

在GitHub创建仓库

Create repository

同步

  • 克隆远程仓库
git clone https://github.com/***/Linear.git
  • 进入克隆的仓库,进行初始化
git init
  • 如果不包含readme.md,则创建并上传README.md文件
$ git init
$ touch README.md
$ git add README.md
$ git commit -m ‘first_commit‘
$ git remote add origin https://github.com/***/Linear.git
$ git push origin master
  • 跟踪项目文件夹中的所有文件和文件夹
$ git add .
  • 输入本次的提交说明
$ git commit -m ‘this_commit‘
  • 关联远程仓库
$ git remote add origin https://github.com/***/Linear.git

origin为远程仓库名,是Git的默认叫法,也可以为别的。

  • 若出现错误 fatal: remote origin already exists,则执行以下语句再关联
$ git remote rm origin
  • 把本地库的所有内容推送到远程库上
$ git push -u origin master
  • 如果在推送时出现错误 error:failed to push som refs to.......,则执行下列语句
$ git pull origin master

将远程库中的内容拉下来再重新推送上去

git本地与github仓库文件同步

原文:https://www.cnblogs.com/rookieveteran/p/12639374.html

(1)
(1)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!