相关疑难解决方法(0)

使'git log'忽略某些路径的更改

git log除了我指定的文件外,我怎么才能只显示改变文件的提交?

有了git log,我可以将我看到的提交过滤给那些触及给定路径的人.我想要的是反转该过滤器,以便只列出除指定的触摸路径以外的触摸路径.

我可以得到我想要的东西

git log --format="%n/%n%H" --name-only | ~/filter-log.pl | git log --stdin --no-walk
Run Code Online (Sandbox Code Playgroud)

在哪里filter-log.pl:

#!/usr/bin/perl
use strict;
use warnings;

$/ = "\n/\n";
<>;

while (<>) {
    my ($commit, @files) = split /\n/, $_;

    if (grep { $_ && $_ !~ m[^(/$|.etckeeper$|lvm/(archive|backup)/)] } @files) {
        print "$commit\n";
    }
}
Run Code Online (Sandbox Code Playgroud)

除了我想要比这更优雅的东西.

请注意,我不是在问如何让git忽略这些文件.跟踪和提交这些文件.就是这样,大多数时候,我对看到它们并不感兴趣.

相关问题:如何反转`git log --grep = <pattern>`或如何显示与模式不匹配的git日志除了提交消息而不是路径之外,它是同一个问题.

关于这个主题的论坛讨论从2008年开始:Re:从git-diff中排除文件这看起来很有希望,但线程似乎已经枯竭了.

git

108
推荐指数
2
解决办法
2万
查看次数

从git空白检查中排除Jest快照

我正在使用git提交修剪空白git diff-index --check --cached HEAD --.我想使用快照添加Jest测试,但快照文件包含空格,如果删除它,我的测试将始终失败.所以我想*.js.snap从空白检查中排除文件.如何告诉git从中排除*.js.snap(或替代**/__snapshots/*)文件git diff-index?我在OSX上使用bash.

与此同时,我正在通过将提交挂钩更改为交互式来解决此问题:

# If there are whitespace errors, print the offending file names and fail.
git diff-index --check --cached HEAD --
if [ $? -ne 0 ]; then
    # Allows us to read user input below, assigns stdin to keyboard
    exec < /dev/tty

    while true; do
        echo "Your commit introduces trailing whitespace.  Are you sure you want to commit? y/n"
        read yn
        case $yn …
Run Code Online (Sandbox Code Playgroud)

git whitespace githooks jestjs

8
推荐指数
1
解决办法
1081
查看次数

标签 统计

git ×2

githooks ×1

jestjs ×1

whitespace ×1