本地仓库连接远端仓库 git pull 和 git push

1. 本地没有项目

  1. 新建远程仓库
  2. 创建一个空文件夹,然后git clone 远程仓库地址
  3. 新建 .gitignore 文件
  4. 在此文件夹开始新建项目

2. 本地已经存在项目

奇淫巧技

  1. 创建一个空文件夹,然后git clone 远程仓库地址
  2. 将本地项目复制到该文件夹,新建 .gitignore 文件,然后提交

实践

方式一:

  1. 打开本地项目文件夹,右键菜单 git bash here,或者在命令行中 cd 到项目文件夹
  2. git 初始化 git init新建 .gitignore 文件
  3. 将项目提交到暂存区 git add .
  4. 连接本地仓库和远程仓库 git remote add 远程仓库地址,默认为 origin
  5. 获取远程仓库的最新代码git pull --allow-unrelated-histories
    1. git fetch
    2. git merge --allow-unrelated-histories
  6. 将项目提交到本地仓库git commit -m 本次提交的说明信息
  7. 推送到远程仓库git push -u

方式二:

  1. 打开本地项目文件夹,右键菜单 git bash here,或者在命令行中 cd 到项目文件夹
  2. git 初始化 git init新建 .gitignore 文件
  3. 将项目提交到暂存区 git add .
  4. 连接本地仓库和远程仓库 git remote add 远程仓库地址,默认为 origin
  5. 新建同名本地分支建立跟踪关系:**git checkout --track /**
  6. 获取远程仓库的最新代码

你可能感兴趣的:(Git,git,github,http,前端,svn)