简体   繁体   中英

On GitHub, how to compare between a certain commit and the current head of a branch?

On GitHub, there's a way to do a "diff" between 2 commits. https://help.github.com/en/github/committing-changes-to-your-project/comparing-commits

In a nutshell, it looks like this: https://github.com/github/linguist/compare/c3a414e..faf7c6f

If I wanted to compare between a certain commit in history vs. the current head of the branch, how would I do this? I don't want to always have to always look up the 7-character SHA code of the latest commit.

I've tried https://github.com/github/linguist/compare/c3a414e..head but that doesn't work.

Give it the name of the branch.

https://github.com/github/linguist/compare/c3a414e..master

You can do it manually, or use the base and compare drop downs.

In general, commit IDs, branch names, and tags are interchangeable. They are all "revisions" which specify a commit. See gitrevisions for the ways you can identify commits. For example, you can compare against where master was two years ago.

https://github.com/github/linguist/compare/c3a414e..master@{2 years ago}

head did not work because the names are case-sensitive. It is HEAD . HEAD is a special reference. On your local repository HEAD is the currently checked out commit. On Github it will be the tip of the default branch on Github, probably master . If you want master you're better off asking for master .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM