stevec
stevec

Reputation: 52208

Get diff between a previous commit and latest commit?

Is there a way to use this technique to compare a certain commit with the latest commit, whilst avoiding manually specifying the SHA of the latest commit?

Here's the method in the linked answer:

https://github.com/<username>/<repo>/compare/<commit>...<commit>

It would be very handy to be able to have a link that will always return the diff between a certain commit and the latest commit. For example, the following will return the diff between the first commit and the latest, but if the repo owner makes more commits, the url must be updated in order to still return the diff between the first and last commits:

https://github.com/adamjstevenson/stripe-connect-managed-rails/compare/29fb2ca2b68ed82c656163554a5f1449effa33ad...d33adf154e2f376cd7d22337c439459f88074723

What I'm hoping for is something like

https://github.com/adamjstevenson/stripe-connect-managed-rails/compare/29fb2ca2b68ed82c656163554a5f1449effa33ad...<latest>

So that no matter how many new commits there are to the master branch of the repository, the url will always display the diff between a commit and the latest commit (without having to manually update the url with the latest commit SHA).

Upvotes: 1

Views: 95

Answers (1)

VonC
VonC

Reputation: 1323145

From what I have tested, the following URL works:

https://github.com/adamjstevenson/stripe-connect-managed-rails/compare/29fb2ca2b68ed82c656163554a5f1449effa33ad...master

That means the second commit can be the name of a branch, which will represent the "latest" in your comparison.

Upvotes: 1

Related Questions