Я работаю через git ребаз, и я уже несколько раз принимал решения о файлах, удаленных нами, добавленных нами, удаленных ими и т. Д. c.
Есть ли способ заставить git показать мне только одно подмножество этих файлов? Таким образом, я могу перенаправить вывод в xargs
и работать с набором файлов в одном go.
Другими словами, если у меня есть это:
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 в конечном итоге решает, какой статус go для файла.
Я также посмотрел --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
Конечно, я мог бы использовать grep
и sed
или что-то еще, чтобы отфильтровать строки и извлечь текст, но мне интересно, есть ли git -только способ решить эту проблему ,