| layout | title | questions | objectives | time_estimation | subtopic | key_points | contributors | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
tutorial_hands_on |
Contributing with GitHub via its interface |
|
|
20m |
contribute |
|
|
Introduction
{:.no_toc}
All the training material which you find on [{{ site.url }}{{ site.baseurl }}/]({{ site.baseurl }}/) is stored on a GitHub repository ([{{ site.github_repository }}]({{ site.github.repository_url }})), a code hosting platform for version control and collaboration. GitHub interface is quite intuitive and simplifies the contributions from anyone.
Agenda
In this tutorial, you will learn how to use GitHub interface to contribute to the training material:
- TOC {:toc}
{: .agenda}
GitHub
The GitHub repository for the training material is: [{{ site.github_repository }}]({{ site.github.repository_url }}).
{% icon hands_on %} Hands-on: Familiarization with GitHub
{: .hands_on}
This CONTRIBUTORS.yaml file is where we collect the information (name, email, etc) about the different contributors to display them on our [Hall of Fame]({% link hall-of-fame.md %}). You will add your information there. But first you need to sign in to GitHub to be able to change this file.
{% icon hands_on %} Hands-on: Sign in to GitHub
{: .hands_on}
Edit a file
You can now modify the CONTRIBUTORS.yaml file to add your information there
{% icon hands_on %} Hands-on: Edit a file
Open the
CONTRIBUTORS.yamlfile on GitHubClick on {% icon hands_on %} icon (top right of the file)
A new page will open:
Modify the
CONTRIBUTORS.yamlby adding yourselfYou should use your GitHub username and add it followed by
:(the:is important) at the correct position given the alphabetical order.Scroll down to the bottom of the file
Fill the Propose file change form
It can also be named Commit changes for the ones with write accesses to the repository
Fill the box "Update CONTRIBUTORS.yaml" with "Add < GitHub username > as contributor" (replace < GitHub username > by your GitHub username)
{% icon comment %} Commit messages
This a commit message: a description explaining why a particular change was made. Theses messages capture the history of the changes, so other contributors can understand what have been done and why {: .comment}
Leave "Add an optional extended description..." empty
Click on Propose file change
{: .hands_on}
Without realizing it, GitHub let you create your first branch (named here patch-1) and add a changement on this branch.
{% icon comment %} Branching
Branching is the way to work on different versions of a repository at one time. By default your repository has one branch named
mainwhich is considered to be the definitive branch. When you create a branch off the main branch, you're making a copy, or snapshot, ofmainas it was at that point in time.By changing a file in this branch, it will diverge from the
mainbranch. It will contain data that is only on this new branch. {: .comment}
Open a Pull Request
Then the addition of your information in the CONTRIBUTORS.yaml file is currently only on your branch patch-1. Not on the main branch and so not only on the [Hall of Fame]({% link hall-of-fame.md %}). You can't add or push directly to the main branch, so you need to create what we call a pull request.
The GitHub interface guides you through this process: after clicking on Propose file change, a new page opens:
{% icon hands_on %} Hands-on: Edit a file
Open and read the [CONTRIBUTING.md]({{ site.github_repository }}/blob/main/CONTRIBUTING.md) file
Come back to the pull request
Fill in the pull request description
Add a title for the Pull Request
Add a message explaining the changes you made
This message is a good way to introduce yourself and to explain the message you made. Be kind and descriptive. It helps the reviewers to understand why you did your changes and if it should be intergrated into the
mainbranch (and then website).{% icon comment %} Pull request messages
GitHub uses Markdown, a simple Markup language, to render the Pull request messages. You can then add bold test, lists, images, etc. {: .comment}
Scroll down and check the changes you made
- In green with
+: what you added- In red with
-: what you deletedClick on Create pull request {: .hands_on}
You have created your first pull request!
Your pull request will be reviewed. There are two possible outcomes:
- Your pull request is accepted. Congratulations! Your changes will be merged into the main branch of the original repository. The website will be re-built and you will be in the [Hall of Fame]({% link hall-of-fame.md %})
- Your pull request needs modifications: the reviewers will ask for some changes, possibly because the automatic tests are failing.
Update a Pull Request
One of the reviewers of your pull request asked you to add your name after your GitHub username in the CONTRIBUTORS.yaml file.
{% icon hands_on %} Hands-on: Update a Pull Request
Go to the list of pull request tab on GitHub
Click on your pull request
You can see here the comments the reviewers left you
Click on Files changed tab and see the changes you made
Click on {% icon hands_on %} icon
Add your name below your GitHub username
It should look like:
bebatut: name: Bérénice BatutNavigate to the bottom of the file
Fill the Commit changes form, similarly to the Propose file change form before
Make sure the Commit directly to the
patch-1branch is selectedClick on Commit changes
The pull request should be automatically updated
Check that the new changes are added to the pull request on GitHub
{: .hands_on}
Conclusion
{:.no_toc}
With this tutorial, you learn how to use GitHub to change a file, create a pull request and then contribute to the training material. What you have learned here can be applied to any file.
{% icon details %} More about GitHub
Via the GitHub interface, you can also go further: create file, branch directly, etc. To learn that, we recommend you to read the GitHub guide {: .details}












