Background image
logologo symbol

3 - The fundamentals

GitHub - Branches and Pull Requests (9 - 11h.)

Description

Introduction

Now that the group project is coming up it is important to practice using tools like Git. When working together in large groups it is important to be able to test out different things in the project without being afraid of ruining the code. This is where git branches come in handy.
The recommended way to work is to:
  1. Invite collaborators to your GitHub repository
  2. Create branch for each feature you are working on
  3. Make a pull request to the main branch
  4. Someone else from your group should then review and merge the pull request, leaving comments on your code
    • This kind of comment is called a "code review"

Topics

  • Git
    • Branches
    • Pull Requests
  • Git Commands
    • git merge
    • git diff
    • git branch
    • git checkout
  • Git workflows

Goals

Knowledge

Know what branches in git are
Know how to merge two branches together
Know how to make a pull request on GitHub

Skills

Be able to use branches to contribute to a project
Be able to use pull requests to contribute to a project

Idea for return

Due to the nature of this project you will need to find someone to work with. It is alright if you are more than two people in a group and in fact you can have as many people in your group as you like, the whole class can work together on this if you like.
The group (two or more students) needs to do the following (do all of this together in person or through Zoom):
BRANCES and pull requests:
  • One student creates a repository with a few files and invites all the other students as collaborators to the repository
  • The students will then receive an email where they need to accept the collaboration
  • The students will then need to do the following:
    • Clone the repository to their own computer
    • Make a new branch in the recently cloned repository
    • Make sure that you are working on the new branch
    • Make some changes to the code
    • Switch to main branch
      • Observe that your changes are not there anymore
    • Switch back to your original branch and observe the changes coming back
    • Push the new code to GitHub by writing "git push origin xxxxx" where xxxxx is the name of your branch
      • Observe the new code in GitHub
    • Make a pull request (on GitHub) with your new branch DO NOT MERGE THE PULL REQUEST
  • When the other people in your group have done that as well you can do the following:
    • Check out pull requests in GitHub
    • Choose one pull request and write a comment to the pull request (code review)
    • Merge the pull request into main
    • Now you should be able to see all the changes on the main branch in your repository.
    • other students can now switch to the main branch and pull the code to get the newest changes