忽略包含对已跟踪文件的更改的目录

时间:2013-01-18 11:12:14

标签: git

我想忽略对跟踪文件进行大量更改的目录?我试过了

d:\git>git update-index --assume-unchanged dir
fatal: Unable to mark file dir

d:\git>git update-index --assume-unchanged dir/*
fatal: Unable to mark file dir/*

d:\git>git update-index --assume-unchanged dir\*
fatal: Unable to mark file dir\*

我尝试强制cmd.exedir\*扩展为dir\file1dir\file2但未成功。我想我的问题是特定于糟糕的Windows控制台。最后我创建了一个批处理文件

git update-index --assume-unchanged dir\file1
git update-index --assume-unchanged dir\file2
git update-index --assume-unchanged dir\file3

有没有办法提供目录而不是所有文件名?

2 个答案:

答案 0 :(得分:2)

您可以在git-bash会话(available with msysgit

中尝试
git update-index --assume-unchanged -- $(git ls-files 'dir/*')

答案 1 :(得分:0)

由于git只跟踪内容(换句话说,文件),因此您需要忽略目录中的每个文件。

我没试过这个,但是有点像:

for f in dir/*; do
    git update-index --assume-unchanged -- $f
done

应该(在理论上)做到这一点。