This course will teach you skills for finding relevant conversations, commits, and projects in a repository.
⛳ Start
We recommend creating a public repository, as private repositories will use Actions minutes.
After you make your own repository, wait about 20 seconds and refresh. I will go to the next step.
Have you ever worked in a repository with a lot of history? Perhaps you've had to track down related issues and pull requests in the past, or you've had to find who committed a particular change. If you've ever found yourself in any of these situations, you'll know how important it is to navigate your workspace.
- Who is this for: Developers, GitHub users, users new to Git, students, managers, teams.
- What you'll learn:
- Find relevant issues and pull requests
- Search history to find context
- Make connections within GitHub to help others find things
- What you'll build: Reposity with existing commits, duplicated isssus and content defect to be fixed.
- Prerequisites: Before you take this course, you may want to go through the Introduction to GitHub course on Learning Lab.
- How long: This course is three steps long and takes less than 15 min to complete.
- Projects Used: docsify, a magical documentation site generator
Welcome to this Learning Lab course about finding your way through the history of GitHub repositories. For example, you could be working in repositories with a lot of history, many collaborators, or many files.
Before you take this course, you may want to go through the [Introduction to GitHub]({{ host }}/{{ course.Owner.login }}/introduction-to-github) course on Learning Lab.
In this course, you'll learn how to do lots of things, like:
- Find relevant issues and pull requests
- Search history to find context
- Make connections within GitHub to help others find things
GitHub has special capabilities to help reference other information on GitHub. For example, when you reference another issue or pull request by number, that number will be hyperlinked. At the same time, a cross-reference is created in the linked issue or pull request. This two-way reference helps people track the relationship of information across GitHub.
⚡ Step 1: Resolve Duplicate Issues
Below, you will see a reference to another issue. The other issue references this issue. The other issue appears to be a duplicate, so it would be a good idea to close it.
When you link to another issue, a reference within GitHub is automatically created. In fact, you don't even need to include the full link. If you were to type #5
within a comment, that would turn into a link to issue or pull request number 5.
When you want to create a crosslink, try typing the title of an issue or pull request directly after you type the #
symbol. GitHub will suggest issues or pull requests that will link to the right place. To learn even more, check out the Autolinked References and URLs article.
- Navigate to the issue #1 (Welcome)
- Type "Duplicate of #2" as a comment and close issue #1
🎯 Step 2: Find a commit in history
An important part of version control is the ability to look into the past. By using git blame
, and finding the story behind a commit, we're able to do more than blame people for code. We're able to see the story around why a commit was made - what is the associated pull request? Who approved the pull request? What tests were run on that commit before it was merged?
The obvious reason to find things in history is to know about history. With issues and pull requests, we see a more complete story about history - not just the bare minimum.
git blame
is a Git functionality that shows what revision and author last modified each line of a file. Information like who made a commit, when, and even why can be found this way. If you aren't sure who introduced certain changes to a file, you can use git blame
to find out. While git blame
sounds rather accusatory, this can be used to understand the context around decisions.
A SHA is a reference to a specific object. In this case, it's a reference to a commit. On GitHub, you can look at a specific commit to see the changes introduced, by whom, and if they were a part of a pull request.
- Navigate to the Code tab of this repository
- Tip: start this process in a new tab, since you will need it later
- Click
docs
to navigate into the/docs
directory - Click
_sidebar.md
to view the file - On the top right side of the file, click Blame to see the details of the most recent revision
- Click the commit message,
add sidebar to documentation
to see the commit details - Copy the first seven characters of the SHA (the first 7 characters of the 40 character hexadecimal string listed after
commit
) - Comment on issue #2 by adding the SHA from step 6 as a comment text and click on "Comment" button
🔧 Step 3: Fix a broken sidebar
Thanks for finding that commit! We now know that the sidebar was indeed added, and it was done in that commit. Let's see if we can dig a little deeper to find out if any planning or conversation occurred around this change.
As we've already seen, conversations in issues and pull requests can reference other work.
But the amount of context goes much further than crosslinks - Remember, Git is version control! For example, the commit that you found in the last step is connected with much more information:
- Who made the commit
- What other changes were included
- When the commit was made
- Which pull request the commit was a part of
The pull request is important because it goes beyond knowing when a commit happened - you can know why a commit happened. Finding history is not about blaming anyone, but about seeing the bigger picture. Why were decisions made? Who was involved? What were the build outputs and test results for each commit? Who requested changes, and who approved them?
Imagine you find an internal white-paper on a really exciting topic. You're looking for experts to help you research this topic for an upcoming project. When you find this article, you're ecstatic! But, there's no author referenced in the plain text.
You can see that it's written in markdown, and it's versioned in GitHub. It's already a part of the main
branch, but you want to know who was involved in creating this. You use git blame
to see the author(s), and you can find the pull request associated with that branch. Now, you can see who all of the authors were, who the reviewers were, and if there are any other issues or conversations related to this topic.
Just like that, you've found the people at your company who can help move your project forward. 🎉
When you're looking at a commit on GitHub, you can see a lot of information. From this view, you can also find a link to the pull request in which the commit was created. We'll use this in the next step.
- In the main branch Edit the
docs/_sidebar.md
file - Correct the spelling of the reference
(doc-references__.md)
on line 4 by changing it into(doc-references.md)
- Commit the changes on the
fix-sidebar
branch - In the Pull requests tab, create a pull request by comparing 'main' branch to 'fix-sidebar' bramch
- Using the Assignees section on the right side, assign yourself to the pull request
- In the PR comment add 'Closing #2' and autolink issue #2
- Merge this pull request
- Delete the branch 'fix-sidebar'
🏁 Finish
In this course, you've learned a lot about finding and sharing information. Within a GitHub repository, you can find history about what changes were made, and more importantly, why changes were made.
- We'd love to hear what you thought of this course in our community forum.
- Take another GitHub Learn course.
- Read the GitHub Getting Started docs.
- To find projects to contribute to, check out GitHub Explore.
Get help: Post in our community forum • Review the GitHub status page
© 2022 GitHub • Code of Conduct • CC-BY-4.0 License