I want to list the files present in another branch without doing a checkout, and according to View a file in a different Git branch without changing branches, this command is sufficient:
git show mybranch:mydir
Unfortunately, the output is not ideal because of the completely unnecessary tree mybranch:mydir:
tree mybranch:mydir
.gitignore
Makefile
README
How can I list the files in another branch without getting any extra information (e.g. tree mybranch:mydir)?
That would then be
git -p ls-tree -r --name-only mybranch:mydir
Drop -p if you do not need the pager. Drop -r if you do not want to descend into directories recursively.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With