I'd like to be able to find the number of files in a Git repository at a given revision, preferably without having to check out the revision first.
I thought git ls-files
might get me somewhere, but I'm not able to see any way of passing Git a revision for it.
Thanks in advance!
The git ls-files command by itself prints out a list of all the tracked files in the repository, one per line. The | operator funnels the output from the preceding command into the command following the pipe. The wc -l command calls the word count (wc) program.
This command will list the files that are being tracked currently. If you want a list of files that ever existed use: git log --pretty=format: --name-only --diff-filter=A | sort - | sed '/^$/d'This command will list all the files including deleted files.
Add branch revision number for tracking of the source code version of a branch in automated builds using "git rev-list --count --first-parent"
The git log command displays committed snapshots. It lets you list the project history, filter it, and search for specific changes.
ls-files
operates on the index, which is by nature associated with the current checkout. Use ls-tree
, as in git ls-tree -r --name-only <tree-ish>
. If you just want to count lines, using --name-only
will speed things up by limiting the output.
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