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/

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

  • 相关阅读:
    volley框架使用
    Insert Interval
    candy(贪心)
    Best Time to Buy and Sell Stock
    Best Time to Buy and Sell Stock III
    distinct subsequences
    edit distance(编辑距离,两个字符串之间相似性的问题)
    trapping rain water
    word break II(单词切分)
    sudoku solver(数独)
  • 原文地址:https://www.cnblogs.com/acm-bingzi/p/gitCheckout.html
Copyright © 2011-2022 走看看