Using git and github

Using git and github

"Learning the basics of version control using git, as well as the social coding platform called github."

Information

The estimated time to complete this training module is 4h.

The prerequisites to take this module are:

If you have any questions regarding the module content please ask them in the relevant module channel on the school Discord server. If you do not have access to the server and would like to join, please send us an email at school.brainhack@gmail.com.

Resources

This module was written by Elizabeth Dupre and Jenny Tou.

Jenny Tou wrote the git concept module. She initially presented her workshops at Brigham and Women’s Hospital in 2019. The video found here is a shortern version of the original presentation. Please contact Jenny for the complete presentation materials.

Elizabeth Dupre presented her material during the QLSC 612 course in 2020, with content adapted from the software carpentries by Elizabeth Dupre.

All her tutorial notes are available here.

The video of her presentation is available below:

ATTENTION!

For the last lecture of the Introduction to Git and GitHub module (Pull Requests) please use this repo under Brainhack School 2022 Github organization to complete the tutorial instead of the one indicated in the tutorial (due to it is no longer in use.). Thank you!

Github authentication methods have changed! Please find the latest documentation.

Git Concept

This is a 10 minutes walk through of basic git concepts for people who wants a refresher!

Exercise

  • send a request at the “Using Git and Github” module post at the modules channels of Discord server by typing “@ please add my ” to the github organization." This will alert your local TA(s) to add you to the school-brainhack organization.
  • create a new repository within the school-brainhack organization following the naming convention <last_name>_project. Don’t worry, you will be able to change this name later, and possibly merge the content in another repository if you decide to team up with other people.
  • initialize your repo with a README and a LICENSE.
  • Create an issue for adding a short bio.
  • Using the command line, clone the repository locally to your computer.
  • Create a branch named after the issue, e.g. iss1.
  • Add a short bio to the README, including a picture of your github avatar. You can adapt the following snippet
<a href="https://github.com/pbellec">
   <img src="https://avatars.githubusercontent.com/u/1670887?v=4?s=100" width="100px;" alt=""/>
   <br /><sub><b>Pierre bellec</b></sub>
</a>

This is a bit of html, which gets rendered in markdown documents. You will need to click on your profile picture to figure out what to replace 1670887 with the ID of your profile picture. Don’t forget to replace pbellec by your github handle.

  • Using the command line, commit this change to your local repository. Make sure you registered your github user name and email address, so the commit is accurately credited to you when you push it on github.
  • Using the command line, push the branch and your changes to the github repository.
  • Using the github interface, open a new pull request with your changes. Use a descriptive name for the pull request, e.g. iss1 - add bio.
  • Using the github interface, request a review of your changes by your local TA (by choosing their github handle among the listed ones).
  • Once your local TA has approved the review, merge the pull request to the main branch.
  • Close the issue.
  • Follow up with your local TA(s) to validate you completed the exercises correctly.
  • 🎉 🎉 🎉 you completed this training module! 🎉 🎉 🎉

More resources

Here is an interactive page to learn Git and visually observe how the branching works under version control.

For more detailed instructions please check GitHub’s resources

Please also check The Turing Way’s guideline or Mozilla GitHub documentation for using GitHub for open research.

For common Mistakes and Experiences with using Git and Github: dangitgit.com

If you are curious to learn more advanced capabilities for git, you can check this tutorial “Effective use of git” by Ankur Sinha organized for the INCF/OCNS software working group.