Git diff表示子项目很脏 [英] Git diff says subproject is dirty

查看:1051
本文介绍了Git diff表示子项目很脏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚运行了一个git diff,并且为大约10个子模块获取了以下输出:

  diff --git a / .vim / bundle / bufexplorer b / .vim / bundle / bufexplorer 
--- a / .vim / bundle / bufexplorer
+++ b / .vim / bundle / bufexplorer
@@ -1 +1 @@
- 子项目提交8c75e65b647238febd0257658b150f717a136359
+子项目提交8c75e65b647238febd0257658b150f717a136359-dirty

这是什么意思?如何修复它? 解决方案

正如Mark Longair的博客文章 Git Submodules Explained


1.7.0及更高版本的git在git的行为中包含恼人的更改 submodule。

子模块现在被认为是脏的,如果它们具有任何修改的文件或未跟踪的文件,而以前只有在子模块中的HEAD指向错误提交。


git子模块输出中加号( + )的含义已经改变,并且第一次你遇到这个问题需要一点时间才能找出错误,例如通过查看更新日志或在git.git上使用git bisect来查找更改。用户可以为在指定版本中,但是很脏引入不同的符号,这对用户来说会更好。


您可以修复它通过:


  • 在返回父回购之前提交或撤销每个子模块中的更改/差异不应再报告脏文件)。要撤消子模块的所有更改( cd )到子模块的根目录中,并执行 git checkout。



    dotnetCarpenter comments 你可以做一个: git submodule foreach --recursive git checkout。


  • 或添加 - ignore-submodules 到你的 git diff ,暂时忽略那些脏的子模块。




Git版本1.7.2中的新功能



由于 Noam 下面的评论

  git status --ignore-submodules = dirty 


I have just run a git diff, and I am getting the following output for all of my approx 10 submodules

diff --git a/.vim/bundle/bufexplorer b/.vim/bundle/bufexplorer
--- a/.vim/bundle/bufexplorer
+++ b/.vim/bundle/bufexplorer
@@ -1 +1 @@
-Subproject commit 8c75e65b647238febd0257658b150f717a136359
+Subproject commit 8c75e65b647238febd0257658b150f717a136359-dirty

What does this mean? How do I fix it?

As mentioned in Mark Longair's blog post Git Submodules Explained,

Versions 1.7.0 and later of git contain an annoying change in the behavior of git submodule.
Submodules are now regarded as dirty if they have any modified files or untracked files, whereas previously it would only be the case if HEAD in the submodule pointed to the wrong commit.

The meaning of the plus sign (+) in the output of git submodule has changed, and the first time that you come across this it takes a little while to figure out what’s going wrong, for example by looking through changelogs or using git bisect on git.git to find the change. It would have been much kinder to users to introduce a different symbol for "at the specified version, but dirty".

You can fix it by:

  • either committing or undoing the changes/evolutions within each of your submodules, before going back to the parent repo (where the diff shouldn't report "dirty" files anymore). To undo all changes to your submodule just cd into the root directory of your submodule and do git checkout .

    dotnetCarpenter comments that you can do a: git submodule foreach --recursive git checkout .

  • or add --ignore-submodules to your git diff, to temporarily ignore those "dirty" submodules.

New in Git version 1.7.2

As Noam comments below, this question mentions that, since git version 1.7.2, you can ignore the dirty submodules with:

git status --ignore-submodules=dirty

这篇关于Git diff表示子项目很脏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆