Stevoisiak
Stevoisiak

Reputation: 26742

How can I compare changes against a GitHub project's first commit?

On GitHub, you can compare changes between two branches or tags by appending /compare to the repository path.

For example: let's say I wanted to view all commits for Notepad++ since the last major release. (Comparing v7.4.2 against HEAD)

I take the project's repository URL, (https://github.com/notepad-plus-plus/notepad-plus-plus/), and append compare/v7.4.2...HEAD.

While I can use HEAD to refer to the last commit in a project's history, I can't figure any way to reference the first commit in a project's history.

Is it possible to compare a tag or commit against the first commit in a GitHub project's history?

I've already tried compare/TAIL...v7.4.2, but that just leads to a page stating "There isn’t anything to compare"

Upvotes: 2

Views: 577

Answers (1)

Bovarysme
Bovarysme

Reputation: 453

There's no symbolic ref like HEAD that references the first commit. One way to find the initial commit ID is to clone the repository and run git log --reverse or git rev-list --format=%B --max-parents=0 HEAD, which will list all commits accessible from HEAD with no parents. The initial commit will be included in that list. You can then use its ID to compare it to another commit or a tag on GitHub.

Here's an example with the notepad-plus-plus repository:

$ git log --oneline --reverse | head -n 1
ec7b0c2d v4.2 ready

Comparing the initial commit with v7.4.2 on GitHub.

Upvotes: 1

Related Questions