zoukankan      html  css  js  c++  java
  • git回滚部分文件到某个版本

      reset 命令只能将整个版本的代码一起回滚,需要使用checkout 命令,可以还原部分文件到某一版本

      格式为:git checkout [<branch>] [file]

    1、首先使用log 命令查看版本号 commit id

      直接使用git log可以查看所有的变更集,也可以指定具体的文件,这样只查看修改了了这个文件的变更集。如下:
      git log E:/Workspaces/WebStormProject/mobile/resources/ios/splash/Default@2x~iphone.png

     

    2、然后最关键的使用checkout命令

    还原单个文件
      git checkout 07ed0f4a1b9118124df26d62ffa8c253ec540207 E:/Workspaces/WebStormProject/mobile/resources/ios/splash/Default@2x~iphone.png

    还原多个文件(使用通配符)
      git checkout 07ed0f4a1b9118124df26d62ffa8c253ec540207 E:/Workspaces/WebStormProject/mobile/resources/ios/splash/Default*.png

    还原文件夹
      git checkout 07ed0f4a1b9118124df26d62ffa8c253ec540207 E:/Workspaces/WebStormProject/mobile/resources/ios/splash/

    使用相对路径(相对路径最开始不能有斜杠)
      git checkout 07ed0f4a1b9118124df26d62ffa8c253ec540207 resources/ios/splash/

    原创文章,欢迎转载,转载请注明出处!

  • 相关阅读:
    shell脚本,通过传入的参数来计算最大值和最小值以及平均值。
    mac date命令
    jstorm系列-2:入门
    jstorm系列-1:入门
    git 如何恢复只是提交到本地的文件(或者commit)
    shell 参数
    shell 运算符
    shell 中的<,<<,>,>>
    shell 学习笔记
    java 多线程剖析
  • 原文地址:https://www.cnblogs.com/acm-bingzi/p/gitCheckout.html
Copyright © 2011-2022 走看看