How to Set up GitHub
What is GitHub?
GitHub is an online software platform for version control and collaboration. By using GitHub, you and your colleagues can work together on projects no matter where you are. In our projects, we use Git not just to improve our teamwork: we also use it to make it more enjoyable. In the end, a team effort not only ensures a better result, but also a more satisfied feeling. Here’s a short guide on how to start using GitHub.
How to use GitHub?
Step 1: create a repository
A repository is mainly used to organize a single project. They contain everything your project needs: folders and files, images, videos, spreadsheets and datasets. We recommend adding a README of your project, or some kind of file on how to get started. GitHub makes it easy to add one when you create a new repository.
This is how you create a new repository:
- Click the plus icon in the top right corner next to your avatar and select ‘New repository’;
- Give it a name and a short description;
- Select ‘Add a README file.
Step 2: create a branch
Branching is a way to simultaneously work on different versions of a repository.
Your repository normally has one branch called ‘main’ that is regarded as the definitive branch. We use other branches to implement changes and experiment with new code, before these new versions are merged with the main branch.
This is how you create a new branch:
- Go to your new repository (the one you just made in step 1);
- Click on the drop-down button called ‘main’, above the file list;
- Type a branchname, for example ‘readme-adjustments’, in the textbox;
- Select the ‘create branch’ box or press Enter.
Step 3: create changes (commits)
This is where the fun begins! GitHub calls saved changes ‘commits’. Each commit has a corresponding message, a description that explains why a change has been applied. These messages capture the history of changes: this way, other users know what you did and why.
Apply and keep changes
- Click on the file ‘README.md’;
- Click the pencil icon in the top right corner to edit the file;
- Write something about yourself in the editor;
- Below the editor, you can describe the changes you just made;
- To implement the changes, click the green ‘Commit changes’ button.
Step 4: open a pull request
Now that your changes are saved in a different branch, you can open a pull request.
Pull requests lie at the core of collaboration on GitHub. When you open a pull request, you propose your changes and you ask a team member to review, download and merge those changes in their branch. Pull requests show the differences between both branches. The changes are shown in red when the changes are deletions: they are green when they are additions.
Step 5: code review
An important step is carrying out a code review, during which you review your peer’s code and check for any mistakes. This way, the quality and consistency of the project are ensured.
Step 6: Merge your Pull Request
You are now ready to definitively apply your changes by merging the readme-edits branch with the main branch.
- Click the green ‘Merge pull request’ button.
- Click the green ‘Confirm merge’ button.
- You can now delete the readme-edits branch by clicking the grey ‘Delete branch’, as your changes have been applied definitively to the main branch.
You have now accomplished:
- Creating an open-source repository;
- Creating and managing a new branch;
- Edited a file and applied the changes in GitHub;
- Opened a Pull Request and merged it.
Good luck with setting up your GitHub environment! If you run into any difficulties, feel free to contact us for help.