gpt4 book ai didi

SVN Changelist 的 Git 等效项?

转载 作者:IT王子 更新时间:2023-10-29 00:40:30 24 4
gpt4 key购买 nike

只是好奇 Git 是否有类似 Subversions Changelist 的功能,我发现它在运行中非常方便,我知道我可以运行类似的东西:

cat 'changelistfileimade' | xargs git update

但我很好奇是否也有内置方法?

最佳答案

为此我在谷歌上搜索了更多,我想我已经找到了 TortoiseSVN ignore-on-commit changelist 的替代品我在上面的评论中提到的用例。有问题的命令是 git update-index --assume-unchanged <path/name> . Git 帮助对此有如下说明:

--[no-]assume-unchanged

When these flags are specified, the object names recorded for the paths are not updated. Instead, these options set and unset the "assume unchanged" bit for the paths. When the "assume unchanged" bit is on, Git stops checking the working tree files for possible modifications, so you need to manually unset the bit to tell Git when you change the working tree file. This is sometimes helpful when working with a big project on a filesystem that has very slow lstat(2) system call (e.g. cifs).

This option can be also used as a coarse file-level mechanism to ignore uncommitted changes in tracked files (akin to what .gitignore does for untracked files). Git will fail (gracefully) in case it needs to modify this file in the index e.g. when merging in a commit; thus, in case the assumed-untracked file is changed upstream, you will need to handle the situation manually.

我在 Nick Quaranto's GitReady blog 上找到了选项的解释,其中包括以下内容:

Obviously there’s quite a few caveats that come into play with this. If you git add the file directly, it will be added to the index. Merging a commit with this flag on will cause the merge to fail gracefully so you can handle it manually.

但这对我来说只是成功的一半。下一步是了解您忽略了什么(并希望记住原因)。这是由 this handy comment 提供的由 Abe Voelker 在一个恰当命名的问题上发表。只需编辑您的 .gitconfig包含代码段的文件

[alias]
ignored = !git ls-files -v | grep "^[[:lower:]]"

不要添加 [alias] bit 如果它已经存在于你的文件中。现在git ignored会告诉你这样的事情:

h configs/environment/local.php
h configs/logging/log4php.xml

您可以使用别名更进一步 ignoreunignore包含以下几行:

    ignore = update-index --assume-unchanged
unignore = update-index --no-assume-unchanged

关于SVN Changelist 的 Git 等效项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10606809/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com