git 我如何找到提交给分支的文件列表?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8964666/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how do i find a list of files committed to a branch?
提问by iCodeLikeImDrunk
How do I list all the files that I committed to a specific branch? I've committed about 40+ files to a branch, and I need to find the file names because I am trying to debug something, hard to do when I don't remember the file names.
如何列出我提交给特定分支的所有文件?我已经向一个分支提交了大约 40 多个文件,我需要找到文件名,因为我正在尝试调试某些东西,当我不记得文件名时很难做到。
git log
only gives me a long list of commits but not the actual files.
git log
只给了我一长串提交,而不是实际文件。
采纳答案by Carl
Have you tried git ls-tree?
你试过 git ls-tree 吗?
git ls-tree --name-only -r <branch_name>
--name-only gives you just the file names. -r recurses into sub directories.
--name-only 只给你文件名。-r 递归到子目录。
If you want the name of the sub-directory listed before recursing into it, add -t to the argument list.
如果您希望在递归进入子目录之前列出子目录的名称,请将 -t 添加到参数列表中。
回答by KL-7
If your branch was derived from master
you can use this command to list all new files that where added after branching:
如果您的分支源自master
您可以使用此命令列出分支后添加的所有新文件:
git diff master...new-branch --name-status --diff-filter=A
Available filter for --diff-filter
are:
可用的过滤器--diff-filter
有:
Added (A), Copied (C), Deleted (D), Modified (M), Renamed (R)
回答by Jay Bienvenu
git log --name-only
worked for me.
git log --name-only
对我来说有效。
回答by Greg Hewgill
The git ls-files
command lists all the files that exist in the latest commit on the current branch.
该git ls-files
命令列出当前分支上最新提交中存在的所有文件。
Or, you can use git diff --name-only
to show a list of the files that are different between any two arbitrary commits.
或者,您可以使用git diff --name-only
显示任意两个任意提交之间不同的文件列表。
回答by Dor Shemer
git log --name-status
will give the names and status of changed files in each commit
git log --name-status
将在每次提交中给出更改文件的名称和状态
回答by Newton Singh
git log --name-onlyWorked for me.
git log --name-only对我有用。
回答by Fabien Haddadi
This one can be useful, if you want to know all distinct files that got modified since branching:
如果您想知道自分支以来被修改的所有不同文件,这可能很有用:
git log --name-status develop...branchname | grep -E "^[AMD]\s" | sort -u
git log --name-status develop...branchname | grep -E "^[AMD]\s" | 排序 -u
And this variant will list the subset of them that youmodified:
此变体将列出您修改的其中的子集:
git log --name-status develop...branchname --author= | grep -E "^[AMD]\s" | sort -u
git log --name-status develop...branchname --author= | grep -E "^[AMD]\s" | 排序 -u
回答by puty
回答by Jim
git diff development...crmq-2405 --name-status --diff-filter=A
will list all files that have been added to the new branch that are not in the mail - in this case development
main branch.
将列出所有已添加到新分支但不在邮件中的文件 - 在本例中development
为主分支。
git diff development...crmq-2405 --name-status
This variant will show all files in the new branch
此变体将显示新分支中的所有文件
Generic form:
通用形式:
git diff main_branch...new_branch --name-status
and yes, order does matter.
是的,订单确实很重要。