Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find a commit on GitHub given the commit hash

Tags:

git

github

commit

I am fairly new to Github and have come across an amateur-ish problem.

I have been asked to do a code review and have been provided with a commit hash, however I have tried looking in Git if I can search using commit hashes but couldn't find anything.

Is there a way I can find the changed code just by using the commit hash?

like image 869
dopplesoldner Avatar asked Aug 31 '12 11:08

dopplesoldner


People also ask

How do you pull from a commit hash?

To pull up a list of your commits and their associated hashes, you can run the git log command. To checkout a previous commit, you will use the Git checkout command followed by the commit hash you retrieved from your Git log.

How do I find my GitHub commit ID?

In a different web browser tab, go to your GitHub dashboard . In Your repositories, choose the repository name that contains the target commit. In the list of commits, find and copy the commit ID that refers to the revision in the repository.

How do you check commit with commit ID?

To find a git commit id (or hash), you can simply use the git log command. This would show you the commit history, listing the commits in chronological order, with the latest commit first.

How do you get details of a commit?

`git log` command is used to view the commit history and display the necessary information of the git repository. This command displays the latest git commits information in chronological order, and the last commit will be displayed first.


1 Answers

A URL of the form https://github.com/<owner>/<project>/commit/<hash> will show you the changes introduced in that commit. For example here's a recent bugfix I made to one of my projects on GitHub:

https://github.com/jerith666/git-graph/commit/35e32b6a00dec02ae7d7c45c6b7106779a124685

You can also shorten the hash to any unique prefix, like so:

https://github.com/jerith666/git-graph/commit/35e32b


I know you just asked about GitHub, but for completeness: If you have the repository checked out, from the command line, you can achieve basically the same thing with either of these commands (unique prefixes work here too):

git show 35e32b6a00dec02ae7d7c45c6b7106779a124685 git log -p -1 35e32b6a00dec02ae7d7c45c6b7106779a124685 

Note: If you shorten the commit hash too far, the command line gives you a helpful disambiguation message, but GitHub will just return a 404.

like image 82
Matt McHenry Avatar answered Sep 18 '22 15:09

Matt McHenry