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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 12:48:43  来源:igfitidea点击:

how do i find a list of files committed to a branch?

gitgit-svncommit

提问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 logonly 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 masteryou 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-filterare:

可用的过滤器--diff-filter有:

Added (A), Copied (C), Deleted (D), Modified (M), Renamed (R)

回答by Jay Bienvenu

git log --name-onlyworked for me.

git log --name-only对我来说有效。

回答by Greg Hewgill

The git ls-filescommand lists all the files that exist in the latest commit on the current branch.

git ls-files命令列出当前分支上最新提交中存在的所有文件。

Or, you can use git diff --name-onlyto show a list of the files that are different between any two arbitrary commits.

或者,您可以使用git diff --name-only显示任意两个任意提交之间不同的文件列表。

回答by Dor Shemer

git log --name-statuswill 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

try using smartgit. it is gui client for git. it has very useful UI and is free for non-commercial use.

尝试使用smartgit。它是 git 的 gui 客户端。它有非常有用的用户界面,可免费用于非商业用途。

回答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 developmentmain 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.

是的,订单确实很重要。