Viewing the History of a Repository on GitHub
In an earlier episode, we used git log
on the command line in our local repository to show the commits to our branch.
We can also see the commits to our branch on GitHub. But first we need to push our local branch to GitHub.
Make sure you are on the forecast
branch:
$ git switch forecast
Now we can push our local branch to GitHub:
$ git push
Navigate to your weather
GitHub repo:
Select the forecast
branch from the branch drop down box labelled main
:
Click on Commits
:
This commits page shows all the commits on your branch:
The Git commit unique identifiers (SHAs) here on GitHub match with those shown after running git log
on the command line in your local branch.
Viewing Differences Between Commits
In an earlier episode, we used git diff
on the command line in our local repository to show the differences between two commits on our branch.
We can also see these differences on GitHub.
In a new tab, navigate to your weather
GitHub repo then add compare
to the end of the URL. The URL should follow https://github.com/<your-user-name>/weather/compare
:
Select one of the Git commit SHAs from the Commits
page and add it to the first drop down box labelled base: main
.
Then select a second Git commit SHA from the Commits
page and add it to the second drop down box labelled compare: main
.
The resulting page will show the differences between the two Git commit SHAs:
`
Keypoints
- The
Commits
page displays the history for the specified branch. - Adding
compare
to the end of the repository URL displays differences between commits.