zoukankan      html  css  js  c++  java
  • git fetch pull checkout区别

    Git中从远程的分支获取最新的版本到本地有这样2个命令:
    1. git fetch:相当于是从远程获取最新版本到本地,不会自动merge
    <p style="margin-top: 0px; margin-bottom: 10px; padding-top: 0px; padding-bottom: 0px;"><span style="line-height: 19px; font-family: 'Trebuchet MS', Tahoma, Arial; font-size: 13px;"><span class="pln" style="line-height: 23px; color: rgb(0, 0, 0);">    </span></span><br style="line-height: 23px;" /><span class="pln" style="line-height: 23px; color: rgb(0, 0, 0);">git fetch origin master</span><br style="line-height: 23px;" /><span class="pln" style="line-height: 23px; color: rgb(0, 0, 0);">git log </span><span class="pun" style="line-height: 23px; color: rgb(102, 102, 0);">-</span><span class="pln" style="line-height: 23px; color: rgb(0, 0, 0);">p master</span><span class="pun" style="line-height: 23px; color: rgb(102, 102, 0);">..</span><span class="pln" style="line-height: 23px; color: rgb(0, 0, 0);">origin</span><span class="pun" style="line-height: 23px; color: rgb(102, 102, 0);">/</span><span class="pln" style="line-height: 23px; color: rgb(0, 0, 0);">master</span><br style="line-height: 23px;" /><span class="pln" style="line-height: 23px; color: rgb(0, 0, 0);">git merge origin</span><span class="pun" style="line-height: 23px; color: rgb(102, 102, 0);">/</span><span class="pln" style="line-height: 23px; color: rgb(0, 0, 0);">master</span></p>
        以上命令的含义:
       首先从远程的origin的master主分支下载最新的版本到origin/master分支上
       然后比较本地的master分支和origin/master分支的差别
       最后进行合并
       上述过程其实可以用以下更清晰的方式来进行:
    <p style="margin-top: 0px; margin-bottom: 10px; padding-top: 0px; padding-bottom: 0px;"><span style="font-family: 'Trebuchet MS', Tahoma, Arial; font-size: 12px; line-height: 23px;"><span style="line-height: 19px;"><span class="pln" style="line-height: 23px; color: rgb(0, 0, 0);">git fetch origin master</span><span class="pun" style="line-height: 23px; color: rgb(102, 102, 0);">:</span><span class="pln" style="line-height: 23px; color: rgb(0, 0, 0);">tmp</span></span></span>
    <span style="font-family: 'Trebuchet MS', Tahoma, Arial; font-size: 12px; line-height: 23px;"><span style="line-height: 19px;"><span class="pln" style="line-height: 23px; color: rgb(0, 0, 0);">git diff tmp </span></span></span>
    <span style="font-family: 'Trebuchet MS', Tahoma, Arial; font-size: 12px; line-height: 23px;"><span style="line-height: 19px;"><span class="pln" style="line-height: 23px; color: rgb(0, 0, 0);">git merge tmp</span></span></span></p>
        从远程获取最新的版本到本地的test分支上
       之后再进行比较合并
    2. git pull:相当于是从远程获取最新版本并merge到本地
    <p style="line-height: 23px; margin-top: 0px; margin-bottom: 10px; padding-top: 0px; padding-bottom: 0px;"><span class="pln" style="color: rgb(0, 0, 0);">git pull origin master</span></p>
    上述命令其实相当于git fetch 和 git merge
    在实际使用中,git fetch更安全一些
    因为在merge前,我们可以查看更新情况,然后再决定是否合并
    结束

  • 相关阅读:
    ASP.NET Interview Questions
    [上海]招聘.Net高级软件工程师&BI数据仓库工程师(急)
    访问被拒绝:“microsoft.web.ui.webcontrols”的解决办法
    上海市区广场、商场、大厦中英文对照大全
    文件夹加密码方法
    JavaScript:使用面向对象的技术创建高级 Web 应用程序(转)
    对数据类型而言运算符无效。运算符为 add,类型为 text。
    SQL行列转换
    主成分分析(Principal components analysis)最小平方误差解释
    主成分分析(Principal components analysis)最大方差解释
  • 原文地址:https://www.cnblogs.com/catkins/p/5270384.html
Copyright © 2011-2022 走看看