git diff 中的“index f2e4113..d4b9bfc 100644”如何对应于 gitk 中的 SHA1 ID?

2023-12-30

git diff 的输出中“index f2e4113..d4b9bfc 100644”是什么意思?到目前为止,我假设这些 SHA1 ID 是 from_version..to_version,但我在 gitk 中找不到它们。

$ git --version
git version 1.8.3.4
$ git diff ae1fdc1
diff --git a/README b/README
index f2e4113..d4b9bfc 100644
--- a/README
+++ b/README
@@ -1 +1,3 @@
stuff
+more
+more stuff

“index f2e4113..d4b9bfc 100644”看起来不像 diff 统一格式的一部分。http://en.wikipedia.org/wiki/Diff#Unified_format http://en.wikipedia.org/wiki/Diff#Unified_format

100644 看起来像文件模式,但与 README 文件(660)的模式不对应。

f2e4113..d4b9bfc 是 SHA1 ID 缩写。 'git rev-parse' 给出长 SHA1。以下是上面示例中的所有三个短裤:

ae1fdc1 - ae1fdc1e7b2f018a15c421f2f22b7c77215c5d61
d4b9bfc - d4b9bfcd51a3eaf427d337a30b12d1f3dbdd21b4
f2e4113 - f2e41136eac73c39554dede1fd7e67b12502d577

但为什么 ae1fdc1 不对应于 diff 的第一部分或第二部分? 为什么我无法使用 gitk 找到 d4b9bfc 或 d4b9bfc?


编辑:@wiswit 指出this http://www.git-tower.com/learn/git/ebook/command-line/advanced-topics/diffs很好的解释。

f2e4113 and d4b9bfc是文件索引。和git show f2e4113您会在提交之前看到该文件并且git show d4b9bfc显示提交后的文件。

The 组合差异格式是在 git diff 手册页中描述的。

COMBINED DIFF FORMAT
   Any diff-generating command can take the ‘-c` or --cc option to produce a 
   combined diff when showing a merge. This is the default format when showing 
   merges with git-diff(1) or git-show(1). Note also that you can give the `-m’
   option to any of these commands to force generation of diffs with individual 
   parents of a merge.

   A combined diff format looks like this:

       diff --combined describe.c
       index fabadb8,cc95eb0..4866510
       --- a/describe.c
       +++ b/describe.c
       @@@ -98,20 -98,12 +98,20 @@@
               return (a_date > b_date) ? -1 : (a_date == b_date) ? 0 : 1;
         }

       - static void describe(char *arg)
        -static void describe(struct commit *cmit, int last_one)
       ++static void describe(char *arg, int last_one)
         {
        +      unsigned char sha1[20];
        +      struct commit *cmit;
               struct commit_list *list;
               static int initialized = 0;
               struct commit_name *n;

        +      if (get_sha1(arg, sha1) < 0)
        +              usage(describe_usage);
        +      cmit = lookup_commit_reference(sha1);
        +      if (!cmit)
        +              usage(describe_usage);
        +
               if (!initialized) {
                       initialized = 1;
                       for_each_ref(get_name);

    1. It is preceded with a "git diff" header, that looks like this (when -c 
       option is used):

           diff --combined file

       or like this (when --cc option is used):

           diff --cc file

    2. It is followed by one or more extended header lines (this example shows
       a merge with two parents):

           index <hash>,<hash>..<hash>
           mode <mode>,<mode>..<mode>
           new file mode <mode>
           deleted file mode <mode>,<mode>

       The mode <mode>,<mode>..<mode> line appears only if at least one of the 
       <mode> is different from the rest. Extended headers with information 
       about  detected contents movement (renames and copying detection) are
       designed to work with diff of two <tree-ish> and are not used by combined
       diff format.

    3. It is followed by two-line from-file/to-file header

           --- a/file
           +++ b/file

       Similar to two-line header for traditional unified diff format, 
       /dev/null is used to signal created or deleted files.

    4. Chunk header format is modified to prevent people from accidentally
       feeding it to patch -p1. Combined diff format was created for review 
       of merge commit changes, and was not meant for apply. The change is 
       similar to the change in the extended index header:

           @@@ <from-file-range> <from-file-range> <to-file-range> @@@

       There are (number of parents + 1) @ characters in the chunk header for 
       combined diff format.

   Unlike the traditional unified diff format, which shows two files A and B
   with a single column that has - (minus — appears in A but removed in B),
   + (plus — missing in A but added to B), or " " (space — unchanged) prefix,
   this format compares two or more files file1, file2,... with one file X, 
   and shows how X differs from each of fileN. One column for each of fileN is
   prepended to the output line to note how X’s line is different from it.

   A - character in the column N means that the line appears in fileN but it
   does not appear in the result. A + character in the column N means that
   the line appears in the result, and fileN does not have that line (in 
   other words, the line was added, from the point of view of that parent).

   In the above example output, the function signature was changed from both
   files (hence two - removals from both file1 and file2, plus ++ to mean one 
   line that was added does not appear in either file1 nor file2). Also eight 
   other lines are the same from file1 but do not appear in file2 (hence 
   prefixed with +).

   When shown by git diff-tree -c, it compares the parents of a merge commit
   with the merge result (i.e. file1..fileN are the parents). When shown by 
   git diff-files -c, it compares the two unresolved merge parents with the 
   working tree file (i.e. file1 is stage 2 aka "our version", file2 is stage 
   3 aka "their version").
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

git diff 中的“index f2e4113..d4b9bfc 100644”如何对应于 gitk 中的 SHA1 ID? 的相关文章

  • Git 无法识别重命名和修改的包文件

    我有一个名为的java文件package old myfile java 我已经通过 git 提交了这个文件 然后我将我的包重命名为new所以我的文件在package new myfile java 我现在想将此文件重命名 和内容更改 提交
  • Git 的企业采用率?

    最近一些同事之间进行了一场讨论 在当今的软件行业中 如何存在两个不同的世界 面向自由软件 公司的 Question Git 在企业环境中的使用情况如何 您在企业环境中使用 Git 的体验如何 无论如何 我们在工作场所使用 git 每个人都对
  • 部分共享git仓库

    我是 git 新手 我想知道是否支持以下场景 如果支持的话如何支持 即用于设置和更新的 git 命令 可以从三个不同的地方获取存储库 本地 镜像 和 github mirror 完全镜像 local github 镜像 local 但 受版
  • 有没有一个简单的命令可以将分支转换为标签?

    我即将完成将 哑快照 转换为 git 的繁琐过程 这个过程进展得非常顺利 感谢这个重命名过程 https stackoverflow com questions 6628539 how to tell git that its the sa
  • GIT:提交时“致命:无法写入 new_index 文件”

    当我尝试将更改提交到本地存储库时 我收到以下消息 致命 无法写入 new index 文件 As this 线程说明 http luhman org blog 2010 04 05 git fatal unable write newind
  • 为 RHEL 6 安装/构建 git-svn

    我无权访问 RHEL6 存储库 那么在 RedHat Enterprise Linux 6 上构建和 或安装 git svn 工具的最佳方法是什么 通过卸载现有的 yum擦除git 并从源安装最新的来设法安装git和git svn 1 7
  • 有没有办法导入/导出容器绑定脚本

    我有一个插件 它使用 appscripts gs 以及 html js 和 css 文件 目前我们所做的是我们有一个参考 Google 文档 其中有一个脚本项目包含所有这些源代码 但是除了手动复制和粘贴之外 没有办法在 GIT 中保留源代码
  • 使用BFG时可以指定多个文件吗?

    我正在尝试删除通配符无法覆盖的多种类型的文件 我尝试使用多个 delete files 但它不接受它 还尝试将文件全部放在 delete files 之后 但它也不接受它 有没有一种方法可以将它们全部放在一个命令中 如果没有 那么我必须运行
  • npm install 的问题(Angular)

    今天我尝试创建一个新项目 所以我使用这个命令 ng new NAME style less 并在我的cmder中弹出错误和警告 所以我卸载了 Roaming npm 和 npm cache 中的节点和文件 然后我安装了node并再次下载cm
  • Jmeter 和 Bitbucket 服务器负载测试

    我是 Jmeter 的新手 我有一个本地托管的 Bitbucket 服务器 有时 当 Bamboo plan 触发并发 git 克隆操作时 会发现 Bitbucket 服务器变得缓慢 无响应 我必须重新启动服务 我想通过对另一个本地创建的
  • BitBucket 应用程序密码:git 命令行访问有哪些权限?

    我了解如何为 BitBucket 创建应用程序密码 如中所述Atlassian 的应用程序密码信息 https support atlassian com bitbucket cloud docs app passwords and 这个答
  • 在git的远程存储库上创建私有分支

    我想在我们公司的 git 上构建特定的流程 开发人员在他的本地计算机上创建一个分支并在那里提交一些文件 dev 将此分支推送到远程仓库 其他开发者无法访问该分支 经过几轮推动开发人员决定发布他的更改 将他的私人分支合并到公共分支 推动该公共
  • 如何在 Visual Studio 2013 中使用 Git 的外部 diff 工具?

    我找到了这个帖子 http architects dzone com articles how configure diff and merge这解释了如何让 Visual Studio 2013 在比较 Git 中的文件时使用内置 dif
  • 使用 git 合并两个截然不同的分支?

    我有我的master分支和我的verydifferentbranch它们有相同的祖先 大约 300 次提交前 现在verydifferentbranch功能完整我想把它放在master下面branch 进行变基会导致每个补丁都有很多合并冲突
  • Git worktree prune - 它有什么作用?

    我在用着git 版本 2 14 2 windows 2并调用 git worktree add
  • 使用 ssh-keygen 创建 SSH 密钥不会创建 .ssh 文件夹

    我正在尝试使用 msysgit 创建我的公共 私有 rsa 密钥对 我运行这个命令 ssh keygen C email protected cdn cgi l email protection t rsa 一切看起来都很好 我收到消息了
  • 如何存储和计算版本控制历史记录?

    考虑这个简单的 python 代码 它演示了一个非常简单的字典版本控制设计 def build current history current for action key value in history assert action in
  • 显示其 diff 包含特定字符串的所有提交

    正如标题所说 我想找到每个差异包含特定字符串的提交 目前 我使用 git log p filename 它显示了不太像每个差异的界面 我在其中搜索字符串 然后我回溯以找到实际的提交消息 简单的替代方案可能是将 git log p 通过管道传
  • “submodule”似乎是一个 git 命令,但我们无法执行它

    我已经克隆了一个 git 存储库 它是一个 Angular 7 和 NET Core 应用程序 项目中一切正常 但是当我尝试恢复 npm 包时 出现以下错误 Microsoft TeamFoundation Team Explorer Gi
  • 本地提交推送到中央服务器

    在工作中 我们使用 perforce 并被鼓励定期对其进行承诺 我对此很满意 然而 我想运行像 Mercurial 这样的东西 这样我就可以在本地提交正在进行的工作并且不一定编译 运行的东西 然后从中定期提交到中央 perforce 服务器

随机推荐