[转]更新远程代码到本地仓库

更新远程代码到本地仓库

  • 方式一

    1. 查看远程仓库

      $ git remote -v
      
    eoecn https://github.com/**************************(fetch)
    eoecn https://github.com/**************************(push)
    origin https://github.com/**************************(fetch)
    origin https://github.com/**************************(push)
    

    从结果看,远程仓库有两个,一个是eoecn,一个是origin

    1. 从远程获取最新版本到本地

      $ git fetch origin master
      
    From https://github.com/***********************
    * branch	master ->FETCH_HEAD
    

    git fetch orgin master : 从远程的origin仓库的master分支下载到本地的origin master

    1. 比较本地的仓库和远程参考的区别

      $ git log -p master.. origin/master
      
    2. 吧远程下载的代码合并到本地仓库,远程的和本地的合并

      $ git merge origin/master
      
  • 方式二

    1. 查看远程分支,同方式一的第一步

    2. 从远程获取最近版本到本地

      $ git fetch origin master:temp
      
    From https://github.com/***********************
    * [new branch]	master ->temp
    

    git fetch origin master:temp : 从远程的origin仓库的master分支下载到本地并新建一个分支temp

    1. 比较本地的长裤和远程参考的区别

      $ git diff temp
      

      git diff temp : 比较master分支和temp分支的不同

    2. 合并temp分支到master分支

      $ git merge temp
      
    3. 如果不想要temp分支,可以将此删除

      $ git branch -d temp
      

posted @ 2018-04-10 21:01  编程小书童  阅读(115)  评论(0)    收藏  举报