git - 我如何使用 git 列出给定分支中给定目录的文件?

标签 git

考虑到 HEAD 指的是我当前的分支(这不是必需的 master),我将如何列出给定目录的所有版本文件(没有完整的递归内容)?

我尝试过的:

我确实玩过 git log(如“git -> show list of files changed in recent commits in a specific directory”或“How can I search Git branches for a file or directory?”),但不知何故它总是给我太多细节。

我只需要一个目录下的版本文件列表。

最佳答案

我会尝试:

git ls-tree --name-only HEAD -- mydirectory/.

注意:

  • mydirectory 之后的“/.”,以便直接在“mydirectory”下列出树(文件和子目录)。如果没有 '-r' 选项,它将不会递归。
  • '--' 以便清楚地将 git 选项和参数与最后传递的文件/目录分开。

关于git - 我如何使用 git 列出给定分支中给定目录的文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6136717/

相关文章:

ios - 为什么 git 会反复添加和删除 Storyboard <classes> 部分?

git - git autocrlf 设置的权威推荐

linux - 为什么 branch checkout 在 Windows 上这么慢,而在 Linux 上这么快?

Git-svn - 导入完整历史

git - 如何同步两个 *local* 分支

git - 为什么 Mercurial 不需要 "recursive merge strategy"?

git - git 命令概要中的 `()` 是什么意思?

git - 在裸存储库上获取 “fatal: This operation must be run in a work tree?”

git - 我需要 Git 才能在 JetBrains IntelliJ IDEA 中使用 Github 吗?

Git 重置未暂存文件的更改