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).
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.
Creating a repository.
You can create a repository on GitHub, which is a platform for hosting
Git repositories.
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.
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.
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.
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.
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/
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
...
Before starting this assignment, you should have completed the following prerequisites:
a working GitHub account
a working installation of GitHub Desktop
a working installation of VSCode
having taken the tutorial about GitHub https://docs.github.com/fr/get-started/start-your-journey/hello-world (at least read it and understand the main concepts)
a folder structure on your computer to store your projects
.../
IEAP-Projects/
Python-R-Git/ # the folder in which you will work for this assignment
Your mission is to create a GitHub repository with a readme file, so to learn-by-doing the basic features:
Using the web interface of GitHub, create a new repository with the following parameters:
Series00-Git-MyGitHubID
, where
MyGitHubID
is your GitHub ID (e.g.,
Series00-Git-DenisMot
if your GitHub ID is
DenisMot
).
Series00-Git
prefix (so that I can easily find your repository).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.
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…
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:
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).
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.
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…
modify the content of the readme (VSCode).
Add an introduction section including the following ideas:
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.
publish the branch and push the changes to the remote repository on GitHub (GitHub Desktop).
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.
Find a pretty image on the Internet and add it to a new section in your readme file.
You will need:
Commit, push and check the changes in the remote repository on GitHub.
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.
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:
images
in the root of your local repository. You can create
this folder in VSCode or in the Finder/Explorer of your computer.images/my-image.png
if
you put the image in the images
folder.Commit, push and check the changes in the remote repository on GitHub.
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.
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…