Github远程仓库的操作同步

版权声明:本文为博主原创文章,转载请注明出处。 https://blog.csdn.net/lylodyf/article/details/65630742

把本地项目上传到Github

这里的操作前提是按照之前博客把环境SSH都配置好了的。

1. 首先在Github创建存放本地项目的仓库

怎么创建仓库大家肯定已经知道了,之前博客也有提过。
这里写图片描述

2. 创建本地仓库并提交代码进去

  • cd到文件所在目录,并且调用git init初始化为git仓库
    这里写图片描述
  • 将需要上传的项目全部添加到仓库
    git add .
  • 将add的文件提交到仓库
    git commit -m "first commit"

3. 将本地仓库关联到github

  • 复制之前创建的仓库的地址 、
    这里写图片描述
  • 执行下面指令,origin是给这个仓库取的名字
    git remote add origin https://github.com/lylodlig/local-image-selected.git

4. 上传到Github仓库

  • 上传之前先pull合并一下,把read.md文件同步到本地
    git pull --rebase origin master
  • 上传
    git push -u origin master
    如此就上传成功了。

把Github项目clone到本地

  • 首先cd到我们要clone到的本地目录下
  • 复制项目的地址
    这里写图片描述
  • 执行下面指令
    git clone https://github.com/lylodlig/local-image-selected.git
    这样在本地目录下就有了。

猜你喜欢

转载自blog.csdn.net/lylodyf/article/details/65630742