Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get number of files in git repository at any revision

Tags:

git

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!

like image 951
cflewis Avatar asked Jan 31 '11 17:01

cflewis


People also ask

How do I count the number of files in a GitHub repository?

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.

How do I get a list of files in git?

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.

How do I find my git revision number?

Add branch revision number for tracking of the source code version of a branch in automated builds using "git rev-list --count --first-parent"

Which command can check the revision history of a repository?

The git log command displays committed snapshots. It lets you list the project history, filter it, and search for specific changes.


1 Answers

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.

like image 175
Josh Lee Avatar answered Oct 31 '22 11:10

Josh Lee