zoukankan      html  css  js  c++  java
  • git取两次提交的文件列表,包含目录信息

    1.用git rev-list HEAD取得版本号列表:

    在SmartGit中看到的也是这样,验证了我们的猜想:

    取到两个版本号之后,用git diff命令:git diff [--options] <commit>...<commit> [--] [<path>…​]

    这里的[-options]我们填的是--name-status,<commit>指的是版本号,也就是每次版本的散列值,可以填前几位就可以了,git会自动识别。

    --name-status选项,可以输出每个修改的文件的状态,添加,修改,删除还是重命名等。

    输入命令git diff --help可以查看帮助文档:

    --name-status
    Show only names and status of changed files. See the description of the --diff-filter option on what the status letters mean.
    --diff-filter=[(A|C|D|M|R|T|U|X|B)…​[*]]
    Select only files that are Added (A), Copied (C), Deleted (D), Modified (M), Renamed (R), have their type (i.e. regular file, symlink, submodule, …​) changed (T), are Unmerged (U), are Unknown (X), or have had their pairing Broken (B). Any combination of the filter characters (including none) can be used. When * (All-or-none) is added to the combination, all paths are selected if there is any file that matches other criteria in the comparison; if there is no file that matches other criteria, nothing is selected.
    
    Also, these upper-case letters can be downcased to exclude. E.g. --diff-filter=ad excludes added and deleted paths.

    其中M和1.txt之间是 ,后面的是目录和文件,如果是在ubuntu下的话,比如修改了文件夹aa下的my.txt

    则:

    M aa/my.txt

    因为linux上的文件夹目录都是/,windows的,没有测试有需要的可以测试。

    如何要输出到文件中:

    // >> 后加输出文件的路径、文件名和后缀名
     git diff [branchA] [branchB] >>d:/diff/exportname.diff
    linux的重定向命令
    覆盖 git diff [branchA] [branchB] > a.txt
    追加 git diff [branchA] [branchB] >> a.txt

    参考:https://segmentfault.com/q/1010000005033288

    命令的具体参考帮助文档:git diff --help

    用git show命令也可以:

    git show会在下面包含每个文件的对比信息(内容),这将会是大量字符串。

    具体如果有目录下的文件不能显示区别,则两个命令的差异实践几次就会发现,可以解决问题的。

    参考:http://www.01happy.com/git-extract-different-files/

         http://diannaowa.blog.51cto.com/3219919/1671384

  • 相关阅读:
    基础数论--例题
    基础数论--扩展欧几里得算法
    基础数论--欧拉定理,逆元
    基础数论--快速幂
    基础数论--欧拉函数
    基础数论--约数
    数论基础--质数
    图算法--二分图的最大匹配(匈牙利算法)
    WEB/APP开发基础之旅--网页布局
    WEB/APP开发基础之旅--HTML入门2
  • 原文地址:https://www.cnblogs.com/hpcpp/p/7447258.html
Copyright © 2011-2022 走看看