1 Introduction

The content in this series is designed to help you learn by doing the course prerequisites on Git and GitHub, which are essential tools for managing your data analysis pipeline (and for collaborating and sharing with others).

1.1 The logic of working with Git and GitHub

Git and Github are about repositories. A repository is a place where you store your code (and its history, thanks to Git). Technically, a repository is a twofold thing: first, a folder on your local machine and second, a website on GitHub (one is the clone of the other, thanks to Git).

The basic workflow involves creating a repository, making changes in branches, committing those changes, and pushing them to a remote repository on GitHub.

  1. Creating a repository.
    You can create a repository on GitHub, which is a platform for hosting Git repositories.

  2. Working with branches.
    The general rule is that the main branch (named main in GitHub) is the stable version of your code. When you want to work on a new feature (or fix a bug), you create a new branch. This allows you to make changes without affecting the main branch. Once your changes are ready, you can merge the branch back into the main branch.

  3. Committing changes.
    When you make changes to your code, you need to commit those changes. A commit is a snapshot of your code at a specific point in time. It includes a message that describes the changes made. This allows you to keep track of the history of your code and revert to previous versions if needed.

  4. Pushing changes to GitHub.
    Once you have committed your changes, you need to push them to the remote repository on GitHub. This updates the repository on GitHub with your local changes, making them available to others.

1.2 The tools you will use

You will work with Git and GitHub using the following tools:

  • GitHub Desktop: a graphical interface to work with Git and GitHub. It allows you to create repositories, clone them, create branches, commit changes, and push them to GitHub.

  • VSCode: a code editor that allows you to write and edit your code. You can also use it to create and edit files in your repository, such as the readme file.

  • GitHub: the platform where you host your repositories. You can create repositories, view the history of your code, and collaborate with others.

1.3 The organisation of your files on your computer

It is of utmost importance that you organize your files in a way that makes it easy to find and easy to work with.

The structure is as follows:

  • IEAP-Projects/
    This is the main folder where you will store all your projects related to the IEAP Master’s program.

    • Python-R-Git/
      This is the folder where you will store all your projects related to the course “Python, R and Git for data analysis”. Inside this folder, you will create a new folder (a repository…) for each project you work on.

NOTE: At the end of the year, you’ll have a structure like this:

.../
  IEAP-Projects/
    Python-R-Git/         # Python, R and Git for data analysis
    Mathematics/          # Mathematical analysis
    Mechanics/            # Mechanical principles, kinematics, kinetics, muscles and joints
    Dyncamical-Systems/   # Modeling using dynamical systems 
    ...
    Neurosciences/        # Neurosciences of movement and learning 
    Physiology/           # Physiology of adaptation to exercise   
    Time-Series/          # Time series analysis
    Ethics/               # Experimental design and ethics
    ...
    Statistics/           # Probabilities and statistics
    Machine-Learning/     # Machine learning 
    Psychology/           # Exercise physchology, Emotions
    ...

2 Prerequisites

Before starting this assignment, you should have completed the following prerequisites:

3 Your mission

Your mission is to create a GitHub repository with a readme file, so to learn-by-doing the basic features:

3.1 Create a GitHub repository

Using the web interface of GitHub, create a new repository with the following parameters:

  • add a template: no
  • name: Series00-Git-MyGitHubID, where MyGitHubID is your GitHub ID (e.g., Series00-Git-DenisMot if your GitHub ID is DenisMot).
    • Why should I add my GitHub pseudo in the name of the repository? Because GitHub wants a unique name for each repository… and I want all students to have the same Series00-Git prefix (so that I can easily find your repository).
  • description: sum up the objective of this repository, e.g. “This repository is used to learn the basics of Git and GitHub”
  • public or private: you choose
    • What is the difference between public and private? A public repository is visible to everyone, while a private repository is only visible to you and the people you invite.
  • add a README file: yes (your mission is to make it better )
  • add a .gitignore file: no
  • add a license: no

You can see that GitHub has created a new repository for you, with only one file (a README.md file) in the root of the repository. This file is a Markdown file that you can edit to add information about your repository.

3.2 Clone the repository on you computer

Using the web interface of GitHub, you can use the Code button to Open with GitHub Desktop.

Once in GitHub Desktop, you need:

  • the URL of the repository you just created on GitHub
    What shoud the URL look like ? GitHub should have filled it for you with e.g., https://github.com/DenisMot/Series00-Git-DenisMot

  • the local path where you want to clone (make a local copy) the repository
    Where should you clone the repository? In the folder Python-R-Git.

  • the name of the repository on your computer.
    What name should you use for the local copy (clone) of the repository? The exact same name for the local and remote repository…

3.3 Start working locally

Now that you have cloned the repository on your computer, you can start working locally. The working logic is to create a branch, make changes in this branch, commit the changes, and then push the changes to the remote repository on GitHub.

RECAP: You mission is add a nice readme file for your repository: you will create this file locally, then commit and push the changes to the remote repository on GitHub.

The steps are the following:

  1. create a branch named readme in your local repository (GitHub Desktop).
    How should you name a branch? Name the branch for what you plan to do (i.e., working on the readme file).

  2. Open the local repository with VSCode.
    How should you open the local repository in VSCode? You can use the Open in Visual Studio Code button in GitHub Desktop, or you can open VSCode and use the File > Open Folder... menu to select the folder of your local repository.

  3. open the file named README.md (VSCode).
    Where is the file? In the root of your local repository, not in a subfolder. It is the only one file in the repository, so it should be easy to find…

  4. modify the content of the readme (VSCode).
    Add an introduction section including the following ideas:

    • that this is a repository to learn-by-doing the basics of Git and GitHub
    • something about your background about Git and GitHub
    • that you are looking forward to learn more about Git and GitHub
  5. commit the changes in your local repository (GitHub Desktop).
    Where are my changes visible? In the Changes tab of GitHub Desktop, you should see the modified README.md file listed there… if you have saved your changes in VSCode.
    What should you write in the commit message? GitHub Desktop suggests Update README.md, which is good, but you are invited to add more in the box below, e.g., - add introduction section
    What is the purpose of the commit message? It is to describe the changes you made in this commit, so that you (and maybe others) can understand what has been done.

  6. publish the branch and push the changes to the remote repository on GitHub (GitHub Desktop).

3.4 Look at the changes in the remote repository

Now that you have pushed the changes to the remote repository on GitHub, you can check if everything is correct.
- What should you see in the remote repository? You should see the README.md file in the root of the repository, with the content you wrote in Markdown format.
- In what branch should you see the file? In the readme branch, not in the main branch, because you are working in the readme branch.

3.5 Improve the readme file

Find a pretty image on the Internet and add it to a new section in your readme file.

You will need:

  • the URL of the image
  • the Markdown syntax to add an image.
  • the commit message to describe the changes you have made.

Commit, push and check the changes in the remote repository on GitHub.

3.6 Improve the readme file again

Add a 5 lines presentation of your motivation to learn Python R and Git. Make it original and personal.

Commit, push and check the changes in the remote repository on GitHub.

3.7 Add a local image to the readme file

When you want to display an image you’ve generated with Python or R, you need to save the image so that you can display it in your readme file. Here, you will add an image that already exists on your computer to your readme file.

You will need:

  • an image that already exists on your computer (e.g., a screenshot of your code, a plot you generated with Python or R, etc.)
  • the Markdown syntax to add an image (copilot is your friend) Where should you put the image? In a subfolder named images in the root of your local repository. You can create this folder in VSCode or in the Finder/Explorer of your computer.
  • the relative path to the image in your local repository
    What is the relative path? It is the path to the image from the root of your local repository, e.g., images/my-image.png if you put the image in the images folder.
  • the commit message to describe the changes you have made

Commit, push and check the changes in the remote repository on GitHub.

3.8 Summarize what you have learned

Write a 5 lines summary of what you have learned from this assignment.
- What are the main concepts learned?
- What are the main commands used?

Write this summary in the readme file, at the end of the file.

Finish with a conclusion sentence indicating how long it took you to complete this work.

Commit, push and check the changes in the remote repository on GitHub.

4 Conclusion

Congratulations! You have successfully learned the basics of Git and GitHub. You are now prepared to use these tools everyday in your Master’s projects…