gpt4 book ai didi

git - 是否可以不显示来自 git status 的特定文件夹的更改?

转载 作者:行者123 更新时间:2023-12-04 08:34:45 25 4
gpt4 key购买 nike

这是情况,假设我想跟踪 **/data 中的文件但不想看到他们的状态(因为文件太多,我一般不关心那里的细节),这可能吗?

如果我能看到一条简短的消息(没有进一步的细节),那就更好了

new      files in ./a/data/
deleted files in ./b/data/
modified files in ./c/data/
...
这要求太多了吗?
提前致谢!

最佳答案

我还没有尝试过,但也许您可以使用 pathspec 功能来限制结果?git help status在我的机器上显示一个帮助页面

git status [<options>…​] [--] [<pathspec>…​]
pathspec 文档显示的地方:

pathspec

Pattern used to limit paths in Git commands.

Pathspecs are used on the command line of "git ls-files", "git ls-tree", "git add", "git grep", "git diff", "git checkout", and many other commands to limit the scope of operations to some subset of the tree or worktree. See the documentation of each command for whether paths are relative to the current directory or toplevel. The pathspec syntax is as follows:

any path matches itself

the pathspec up to the last slash represents a directory prefix. The scope of that pathspec is limited to that subtree.

the rest of the pathspec is a pattern for the remainder of the pathname. Paths relative to the directory prefix will be matched against that pattern using fnmatch(3); in particular, * and ? can match directory separators.

For example, Documentation/*.jpg will match all .jpg files in the Documentation subtree, including Documentation/chapter_1/figure_1.jpg.

A pathspec that begins with a colon : has special meaning. In the short form, the leading colon : is followed by zero or more "magic signature" letters (which optionally is terminated by another colon :), and the remainder is the pattern to match against the path. The "magic signature" consists of ASCII symbols that are neither alphanumeric, glob, regex special characters nor colon. The optional colon that terminates the "magic signature" can be omitted if the pattern begins with a character that does not belong to "magic signature" symbol set and is not a colon.

In the long form, the leading colon : is followed by an open parenthesis (, a comma-separated list of zero or more "magic words", and a close parentheses ), and the remainder is the pattern to match against the path.

A pathspec with only a colon means "there is no pathspec". This form should not be combined with other pathspec.

topThe magic word top (magic signature: /) makes the pattern match from the root of the working tree, even when you are running the command from inside a subdirectory.

literalWildcards in the pattern such as * or ? are treated as literal characters.

icaseCase insensitive match.

globGit treats the pattern as a shell glob suitable for consumption by fnmatch(3) with the FNM_PATHNAME flag: wildcards in the pattern will not match a / in the pathname. For example, "Documentation/*.html" matches "Documentation/git.html" but not "Documentation/ppc/ppc.html" or "tools/perf/Documentation/perf.html".

Two consecutive asterisks ("**") in patterns matched against full pathname may have special meaning:

A leading "**" followed by a slash means match in all directories. For example, "**/foo" matches file or directory "foo" anywhere, the same as pattern "foo". "*/foo/bar" > matches file or directory "bar" anywhere that is directly under directory "foo".

A trailing "/**" matches everything inside. For example, "abc/**" matches all files inside directory "abc", relative to the location of the .gitignore file, with infinite depth.

A slash followed by two consecutive asterisks then a slash matches zero or more directories. For example, "a/**/b" matches "a/b", "a/x/b", "a/x/y/b" and so on.

Other consecutive asterisks are considered invalid.

Glob magic is incompatible with literal magic.

attr

After attr: comes a space separated list of "attribute requirements",all of which must be met in order for the path to be considered amatch; this is in addition to the usual non-magic pathspec patternmatching. See gitattributes(5).

Each of the attribute requirements for the path takes one of these forms:

"ATTR" requires that the attribute ATTR be set.

"-ATTR" requires that the attribute ATTR be unset.

"ATTR=VALUE" requires that the attribute ATTR be set to the string VALUE.

"!ATTR" requires that the attribute ATTR be unspecified.

Note that when matching against a tree object, attributes are still obtained from working tree, not from the given tree object.

excludeAfter a path matches any non-exclude pathspec, it will be run through all exclude pathspecs (magic signature: ! or its synonym ^). If it matches, the path is ignored. When there is no non-exclude pathspec, the exclusion is applied to the result set as if invoked without any pathspec.

关于git - 是否可以不显示来自 git status 的特定文件夹的更改?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64849232/

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