在git-rebase中只列出由我们删除、由我们添加、由他们删除等文件



我正在处理git rebase,我已经多次决定由我们删除、由我们添加、由他们删除等文件。

有没有办法让git只显示这些文件的一个子集?通过这种方式,我可以将输出通过管道传输到xargs,并一次性处理一组文件。

换句话说,如果我有这个:

added by us:     core/tests/Drupal/Tests/Component/Annotation/Doctrine/Fixtures/AnnotationWithVarType.php
added by us:     core/tests/Drupal/Tests/Component/Annotation/Doctrine/Fixtures/ClassWithConstants.php
added by us:     core/tests/Drupal/Tests/Component/Annotation/Doctrine/Fixtures/ClassWithInvalidAnnotationTargetAtClass.php
added by us:     core/tests/Drupal/Tests/Component/Annotation/Doctrine/Fixtures/ClassWithInvalidAnnotationTargetAtMethod.php
added by us:     core/tests/Drupal/Tests/Component/Annotation/Doctrine/Fixtures/ClassWithValidAnnotationTarget.php
deleted by us:   vendor/behat/mink/.gitattributes
deleted by us:   vendor/behat/mink/.gitignore
deleted by them: vendor/doctrine/annotations/CHANGELOG.md
deleted by them: vendor/doctrine/annotations/phpstan.neon
added by them:   vendor/justinrainbow/json-schema/phpunit.xml.dist

例如,我希望能够指定added by us,并且只看到

core/tests/Drupal/Tests/Component/Annotation/Doctrine/Fixtures/AnnotationWithVarType.php
core/tests/Drupal/Tests/Component/Annotation/Doctrine/Fixtures/ClassWithConstants.php
core/tests/Drupal/Tests/Component/Annotation/Doctrine/Fixtures/ClassWithInvalidAnnotationTargetAtClass.php
core/tests/Drupal/Tests/Component/Annotation/Doctrine/Fixtures/ClassWithInvalidAnnotationTargetAtMethod.php
core/tests/Drupal/Tests/Component/Annotation/Doctrine/Fixtures/ClassWithValidAnnotationTarget.php

其他组合也是如此。


ls-files:最接近

$ git ls-files -u
100644 31f22a4cec3c5e170077bcfebc2208d2b37fe075 2       core/tests/Drupal/Tests/ComponentAnnotation/Doctrine/Fixtures/ClassWithInvalidAnnotationTargetAtClass.php
100644 9ee0a27f86c900240e781ab103e1bdc6fab957ba 2       core/tests/Drupal/Tests/ComponentAnnotation/Doctrine/Fixtures/ClassWithInvalidAnnotationTargetAtMethod.php
100644 505aa27a131e0090af5f2416f240e0cbcee3ff84 2       core/tests/Drupal/Tests/ComponentAnnotation/Doctrine/Fixtures/ClassWithValidAnnotationTarget.php
100644 010e9b933b548c96cb7618844ff160f5e800f6e1 1       vendor/behat/mink/.gitattributes
100644 9db3888aebea01ede0d8a42e87ddb7b430310f90 3       vendor/behat/mink/.gitattributes
100644 66de342a111ac61c9bcba7d19b2372399c8502c3 1       vendor/behat/mink/.gitignore
100644 e3305a8383c4cd841083be61e1b5dcfa31cc4ca0 3       vendor/behat/mink/.gitignore
100644 0b0ba1a71d8c725fa394861e87542b0e612cf738 1       vendor/doctrine/annotations/CHANGELOG.md
100644 c09ebe60107ef2d316321cef1c1bccf5c0545df7 2       vendor/doctrine/annotations/CHANGELOG.md
100644 be267e611cc7a8c7e105f17801e8f2512f56b8fc 1       vendor/doctrine/annotations/phpstan.neon
100644 d2b79a7fd65549181ea808290b13b32dbb78bce0 2       vendor/doctrine/annotations/phpstan.neon
100644 0136d8edcc23976ae263b15acf5512ef57bd9c9e 3       vendor/justinrainbow/json-schema/phpunit.xml.dist

输出的第二列有一个数字,这似乎表明了操作,以及操作由谁执行。但是,我不知道引用它的列或文件属性的名称。我想有些文件会被表示两次,来自不同的提交,但我不确定git最终是如何决定文件的状态的。

我还查看了--diff-filter,但它似乎只能向我显示更改的文件,而不是由谁更改的。

$ git diff --name-only --diff-filter=U
core/tests/Drupal/Tests/Component/Annotation/Doctrine/Fixtures/AnnotationWithVarType.php
core/tests/Drupal/Tests/Component/Annotation/Doctrine/Fixtures/ClassWithConstants.php
core/tests/Drupal/Tests/Component/Annotation/Doctrine/Fixtures/ClassWithInvalidAnnotationTargetAtClass.php
core/tests/Drupal/Tests/Component/Annotation/Doctrine/Fixtures/ClassWithInvalidAnnotationTargetAtMethod.php
core/tests/Drupal/Tests/Component/Annotation/Doctrine/Fixtures/ClassWithValidAnnotationTarget.php
vendor/behat/mink/.gitattributes
vendor/behat/mink/.gitignore
vendor/doctrine/annotations/CHANGELOG.md
vendor/doctrine/annotations/phpstan.neon
vendor/justinrainbow/json-schema/phpunit.xml.dist

当然,我可以使用grepsed或其他东西来过滤行并提取文本,但我想知道是否有只有git的方法来解决这个问题。

列表"被我们删除":

git status --porcelain -uno | sed -n 's/^DU //p'

链接的答案:https://stackoverflow.com/a/69558302/1300170

相关内容

最新更新