How to Count Total Lines of Code in a GitHub Repository

0 Comments
Editor Ratings:
User Ratings:
[Total: 0 Average: 0]




When it comes to GitHub repositories, we can open any file and find out the total number of lines of code in it. But there is no native method to figure out the number of lines of code in the entire project or repository. This is precisely why ghloc-web has been developed and in this article we will be explaining the steps for using this website for the required information.

ghloc-web is a free open-source website that enables you to count the total lines of code in a GitHub repository as well as display additional information about the repo. All that you need to do is paste the URL of the GitHub repository and ghloc-web will fetch the complete information for you as follows:

  1. Repo Health
  2. Total Number of Commits along with a chart that indicates the Repo Commit Activity for the past year.
  3. Bundle size of an npm package
  4. Total lines of Code
  5. Total lines of Code that you can Sort and Filter as per your requirements.

How it Works:

1. Click on this link to navigate to ghloc-web.

2. Copy the URL of the GitHub repository that you wish to study and paste it in the search box.

3. Ghloc-web will automatically search for the Repository and display it below the box. Click on it to get the required information.

Paste Repo URL

4. You will now be navigated to the main page that provides the detailed information about the Repository.

5. The Repo Size, Health (in percentage) and details of npm packages (if any) will be displayed in the top section.

Repo Health

6. The total number of Commits will be shown below the Repo Health along with the Repo Commit Activity for the last year.

Commit Activity

7. Browse further down and you will be able to see the total Lines of Code in the Repository.

8. The left column gives you the list of Folders and Files in the Repository along with the number of Lines of Code and the percentage in comparison to the total Lines of Code in the repository.

Repo Files left column

9. You can sort this list based on File type or Locs (lines of code) using the adjacent drop down.

Sort by LOCS
Sort by LOCS
Sort by Type
Sort by Type

10. The column on the right shows the Lines of Code by file extension along with the percentage as compared to the total Lines of Code in the entire project.

Repo Files right column

11. If you click on any file extension in this list, the corresponding files as well as the parent Folder that contains them will be highlighted in the column on the left.

json

12. Click on any Folder to open it and get the count of Lines of Code for the Files that it contains as we have seen above for the entire Repository.

Scripts folder

13. You can Filter the above lists by typing the string in the text box beside the ‘Sort’ drop down.

Few examples:

.js will only include paths containing .js.

.js$ will only include the files with .js extension.

‘!test’, ‘!.lock’ will ignore the paths that contain test or .lock.

js filter

You can click on the ‘question mark’ icon in this box to learn more about filtering options.

 Closing Comments:

ghloc-web is a fine website that gives you the Lines of Code in a GitHub repository as well as other essential information such as Repo health, Repo size, Total number of Commits, Repo Commit activity, and more. GitHub does not provide all of this information natively in its Repository.

Click here to navigate to ghloc-web. To access the Source Code of ghloc-web, click here.

Editor Ratings:
User Ratings:
[Total: 0 Average: 0]
Free/Paid: Free

Leave A Reply

 

Get 100 GB FREE

Provide details to get this offer