git update-index - 在目录上没有改变 [英] git update-index --assume-unchanged on directory
问题描述
git 1.7.12
我想将指定目录下的所有文件标记为假定不变。
1) git update-index --assume-unchaged dir /
给出忽略路径。
2) git update-index --assume-unchaged dir / *
会很快失败,没有被跟踪,因此它给出致命:无法标记文件并退出。
3)尝试生成要标记的文件列表。 cd
进入所需目录,然后运行 git ls-files | tr'\\\
。这不会生成错误消息,但它不能成功标记文件。命令的第一部分,
'''| git update-index --assume-unchanged git ls-files | tr'\\\
,正确地产生一个空格分隔的所有我要标记的文件列表。如果我复制并粘贴命令的输出到命令行,然后
''' git update-index
命令工作。
不,我不能将 dir
添加到.gitignore 。我需要这些文件在存储库中,但不期望的更改将在本地进行,需要被忽略,以便用户可以做拉。
git update-index
需要命令行上的文件名,不是它的标准输入。
步骤1:
cd
步骤2:
git update-index --assume-unchanged $(git ls-files | tr'\\\
''')
或
ls-files | tr'\\\
'''| xargs git update-index - 不变的
有问题。如果你有这些,你可以使用这:
git ls-files -z | xargs -0 git update-index - 不变的
编辑:合并来自@MatthewScharley的输入关于 git ls-files -z
。
Windows命令
< >
注意:如果您使用的是Windows,请使用 Git Bash 运行这些命令
git 1.7.12
I want to mark all files below a given directory as assume-unchanged.
1) git update-index --assume-unchaged dir/
gives "Ignoring path."
2) git update-index --assume-unchaged dir/*
quickly fails because it will encounter files which are not being tracked, hence it gives "fatal: Unable to mark file" and quits.
3) Try generating a list of files to mark. cd
into the desired directory and then run git ls-files | tr '\n' ' ' | git update-index --assume-unchanged
. This produces no error message, but it does not successfully mark the files. The first portion of the command, git ls-files | tr '\n' ' '
, correctly produces a space delimited list of all the files I want to mark. If I copy and paste the output of that command onto the command-line, then the git update-index
command works. What is not working with the pipes?
No, it is not sufficient for me to add dir
to .gitignore. I need these files to be in the repository, but undesired changes will be made locally that need to be ignored so that users can do pulls.
git update-index
wants the file names on it's command line, not on it's standard input.
Step 1:
cd
into the folder you want to assume is unchanged,
Step 2:
You can do either this:
git update-index --assume-unchanged $(git ls-files | tr '\n' ' ')
or
git ls-files | tr '\n' ' ' | xargs git update-index --assume-unchanged
Although, with either case, file names with spaces will be problematic. If you have those, you can use this:
git ls-files -z | xargs -0 git update-index --assume-unchanged
Edit: incorporated input from @MatthewScharley regarding git ls-files -z
.
Windows Commands
Note: If you're on windows, use Git Bash to run these commands
这篇关于git update-index - 在目录上没有改变的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!