nerc-ceh.github.io

https://nerc-ceh.github.io/version_control/exercise3

Exercise 3. Team working

In the previous exercises you have been the only person working on your Github hosted repository. This may be sufficient for your needs. However, you may be part of a team where you all need to edit the same code base in a managed way. In this exercise each team member will work on a clone of the same Github repository and share their changes to the others via Github using Pull and Push actions.

To do this effectively you will also learn about Branching and Merging. So far, all your commits have been to the default branch - this branch is called master. You may have already noticed master in SourceTree as highlighted here (under the Log/History tab):

However, it is common to create new branches for specific pieces of work. This isolates your changes from the master branch, and any other branch that may have been created. It is only when you are ready that these changes are merged from your new branch into the master branch (or potentially any branch) via a Pull Request. This is very useful in busy projects with multiple editors and lots going on. There is more than one way to create a branch, in this exercise you will do it via Github.

Overall you will learn about:

Prerequisites: On-line

To participate in this exercise you need to be on-line. There should at least be wifi available during the workshop, so please use that.

Step 1. Form a team

Step 2. Collaborate on one of your Github repositories

Step 3. Collaborators clone repository

Everyone needs a local clone of the repository. The owner should already have one. However, the collaborators (ie other team members) must clone it from Github. Follow the instructions from Exercise 2 Step 3 and use the URL of the repository you are collaborating on.

Step 4. Create a new branch via Github

The team needs to do some urgent work documenting Giraffes! One person should now create a new Giraffes branch in Github ready for the whole team to checkout and work on.

Step 5. Fetch and checkout the new branch

Everyone now needs the giraffe branch in their local repository so they can work on the files. This is a two stage process.

Step 6. Pushing and pulling changes

Time to start working as a team. You will now add some content to the giraffes branch you all have checked out. Two people will work on separate parts and push them up to Github.

Step 7. Conflict resolution

In this step you will learn how to solve the conflicts that arise when two people independently edit the same part of a file with different text. You will create the conflict by both editing the same text, once one of you pushes your change to Github the other will see conflict errors when they try to push their change. You will decide what the correct text should be and push the resolution to Github. So start by creating the conflict…

Step 8. Pull Request

The team has finished all the work for the giraffes branch. It is time to merge it back into the Master branch. We are going to do this by issuing a Pull Request in Github. A pull request engages others in the team to review the work before the branch is merged into the master branch. It can involve discussion threads and additional changes. When they are happy with our changes the branch is merged into master. It is a quality control step that helps ensure that the target branch (usually the master) only contains approved work.

Step 9. Exercises finished, please clean up Github if you’ve finished with them

We hope you found these exercises useful and you continue to learn more about version control with Git as you incorporate it into your working processes.

End of exercises