开发者

How would I list files for a given directory in a given branch with git?

Considering that HEAD refers 开发者_如何学运维to my current branch (which isn't necessary master), how would I list all versioned files of a given directory (without the full recursive content)?

What I have tried:

I did play with git log (as in "git -> show list of files changed in recent commits in a specific directory", or "How can I search Git branches for a file or directory?"), but somehow it always gives me too much details.

I just need the list of versioned files directly under one directory.


I would try:

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

Note:

  • the '/.' after mydirectory in order to list the tree (file and subdirectories) directly under 'mydirectory'. Without the '-r' option, it won't be recursive.
  • the '--' in order to clearly separate the git options and arguments from the file/directory passed at the end.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜