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 '
/.
' aftermydirectory
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.
精彩评论