如何找到提交到 git 分支的文件列表?

发布于 2024-12-28 17:40:43 字数 134 浏览 2 评论 0原文

如何列出我提交到特定分支的所有文件?我已经向分支提交了大约 40 多个文件,我需要找到文件名,因为我正在尝试调试某些东西,当我不记得文件名时很难做到这一点。

git log 只给我一长串提交,而不是实际的文件。

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.

git log only gives me a long list of commits but not the actual files.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

寄风 2025-01-04 17:40:43

你试过 git ls-tree 吗?

git ls-tree --name-only -r <branch_name> 

--name-only 只提供文件名。
-r 递归到子目录。

如果您希望在递归之前列出子目录的名称,请将 -t 添加到参数列表中。

Have you tried git ls-tree?

git ls-tree --name-only -r <branch_name> 

--name-only gives you just the file names.
-r recurses into sub directories.

If you want the name of the sub-directory listed before recursing into it, add -t to the argument list.

吖咩 2025-01-04 17:40:43

如果您的分支源自 master,您可以使用此命令列出分支后添加的所有新文件:

git diff master...new-branch --name-status --diff-filter=A

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

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

If your branch was derived from master you can use this command to list all new files that where added after branching:

git diff master...new-branch --name-status --diff-filter=A

Available filter for --diff-filter are:

Added (A), Copied (C), Deleted (D), Modified (M), Renamed (R)
紫﹏色ふ单纯 2025-01-04 17:40:43

git log --name-only 为我工作。

git log --name-only worked for me.

匿名。 2025-01-04 17:40:43

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

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

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

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

So要识趣 2025-01-04 17:40:43

git log --name-status 将给出每次提交中更改的文件的名称和状态

git log --name-status will give the names and status of changed files in each commit

爱你不解释 2025-01-04 17:40:43
git log --name-only

这对我有用。

git log --name-only

This worked for me.

孤凫 2025-01-04 17:40:43

如果您想知道自分支以来修改的所有不同文件,这一点可能很有用:

git log --name-status 开发...分支名称 | grep -E "^[AMD]\s" | grep -E "^[AMD]\s" |
排序-u

这个变体将列出您修改过的子集:

git log --name-status 开发...branchname --author= |
grep -E "^[AMD]\s" | grep -E "^[AMD]\s" |排序-u

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

And this variant will list the subset of them that you modified:

git log --name-status develop...branchname --author= |
grep -E "^[AMD]\s" | sort -u

黯淡〆 2025-01-04 17:40:43

尝试使用smartgit。它是 git 的 GUI 客户端。它有非常有用的用户界面,并且免费供非商业用途。

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

半窗疏影 2025-01-04 17:40:43
git diff development...crmq-2405 --name-status --diff-filter=A

将列出已添加到新分支但不在邮件中的所有文件 - 在本例中为 development 主分支。

git diff development...crmq-2405 --name-status

此变体将显示新分支

通用形式中的所有文件:

git diff main_branch...new_branch --name-status

是的,顺序确实很重要。

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.

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文