有时会有一些已更改的文件以及一些新的,已删除和/或重命名的文件.在做git diff或者git-log我想省略它们时,我可以更好地发现修改.
实际上,列出新文件和已删除文件的名称是最好的.对于"旧"重命名为"新"我想选择性地区分"旧"和"新".
我想在git分支中搜索我和所有其他文件之间共同修改的文件,作为早期冲突检测的方法.有没有一种方法让git允许我这样做,我忽略(或通过shell脚本)?
我现在想到的方法是作为post-commit钩子:
git diff --name-only master在我正在的分支上执行a ,以确定我将在其他分支中搜索的所有文件(以生成冲突分支的列表)git diff --name-only origin/<remote branch> origin/master根据这个答案,我无法理解 git diff-filter 的“复制”和“重命名”意味着什么: https: //stackoverflow.com/a/6879568/2039203。当我重命名/移动某些文件时,该文件被处理为“添加”和“删除”。
所以问题是:我应该怎么做才能使用以下两个命令过滤一些文件?我是否需要此过滤器选项来获取已添加/已删除文件的列表?
git diff --diff-filter=C --name-only
Run Code Online (Sandbox Code Playgroud)
和
git diff --diff-filter=R --name-only
Run Code Online (Sandbox Code Playgroud) 我们在path/to/another/和中修改了文件path/to/main/.已添加到git缓存中的
文件,path/to/main/但我们已更新path/to/main/Bar.php文件AGAIN.我们现在有以下情况:
$ git status
[...]
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: path/to/main/Foo.php
modified: path/to/main/Bar.php
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: path/to/main/Bar.php
modified: path/to/another/Aaa.php
modified: path/to/another/Bbb.php
Run Code Online (Sandbox Code Playgroud)
(注意路径/到/ main/Bar.php出现两次)
我需要一个可以读取之前添加的文件而不使用特定路径的命令.
PS git add --update将添加所有这些文件.它不起作用.
PPS此命令应该能够读取modified:和输入new file:类型.
UPD1
感谢@AyonNahiyan,是的,它可以在bash中运行.但也许有一个命令没有使用bash技巧(子命令).