The Palos Publishing Company

Follow Us On The X Platform @PalosPublishing
Categories We Write About

Collect Git commit history

To collect Git commit history, you can use the following command in your terminal within a Git repository:

bash
git log

This command displays the commit history, including commit hashes, authors, dates, and messages.

For a Simplified View

You can use --oneline to get a compact version:

bash
git log --oneline

This shows each commit as a single line (commit hash and message).

Customize Output Format

To collect and format the commit history as needed (e.g., for exporting or parsing), use:

bash
git log --pretty=format:"%h - %an, %ar : %s"

Explanation:

  • %h: abbreviated commit hash

  • %an: author name

  • %ar: relative date (e.g., 2 days ago)

  • %s: commit message

Export to a File

To save the commit history to a file:

bash
git log --pretty=format:"%h - %an, %ar : %s" > commit_history.txt

For Specific Branch

To get the commit history for a specific branch:

bash
git log branch-name

For Specific File

To view commit history of a particular file:

bash
git log -- path/to/file

Let me know if you want to parse the commit data programmatically (e.g., in Python, Bash, etc.).

Share this Page your favorite way: Click any app below to share.

Enter your email below to join The Palos Publishing Company Email List

We respect your email privacy

Categories We Write About