git本地仓库push服务器, 本地仓库拉取服务器仓库

2种同步服务器仓库的办法(假设服务器地址为:xxxxx):

第一种方法:

 1. 在服务器上创建一个仓库:git init --bare sample.git

 2. 然后使用git clone服务器仓库到本地:git clone xxxxx/sample.git

 3. 之后便可以用git push向服务器推送更新

第二种办法(适合本地仓库已经存在,需要与服务器第一次push):

    1. 在服务器上创建一个仓库:git init --bare sample.git

2. 在本地仓库里使用命令:git remote add origin xxxxx/sample.git

3. 在本地使用 git push -u origin master便可以向服务器推送数据


2种本地拉取服务器仓库:

 第一种方法
  git fetch --all
  git reset --hard origin/master
  git fetch下载远程最新的, 然后,git reset master分支重置

 第二种方法
  git reset --hard HEAD
  git pull

猜你喜欢

转载自www.cnblogs.com/weishengzhong/p/9427600.html