-
Notifications
You must be signed in to change notification settings - Fork 0
git and GitHub
Git is a version control management system. In short, it helps you avoid this:
It helps you keep track of changes to your files and prevents you making files like script_final.m
, script_FINAL_2.m
, script_FINAL_FINAL.m
. This is super important as we change files all the time and things break! Git provides you an easy way to travel back in time and revive your code from the grave. For each project that you work on, you can set up git so that it 'tracks changes' within that project. Git is a free protocol for saving file changes, developed by Linus Torvalds (the maker of Linux).
GitHub is a freemium service offered by Microsoft to host your git projects (aka repositories or repos) online. Note that the free product is likely to cover all of your (and the lab's) needs. This offers a service for you to back up all your git projects to the cloud. If you spill coffee on your laptop, your code will be saved in the cloud. As an example, you can check out the lab GitHub pages (newer page) (older page), or an example of a personal page here.
Note the main differences between git and GitHub. They are often used closely together, but they are slightly different.
git is the free, open source protocol that is used to track changes in your code.
GitHub is the freemium service operated by Microsoft for saving your git projects onto the cloud.
We recommend installing git on your local machine. It will take ~30-60 mins to set up, but provides many advantages.
- It allows you to download code to run for your own personal uses.
- It allows you to run/test code on your local device (e.g. when MASSIVE is down).
- It familiarises you with coding best practices.
- It allows you test your code in multiple runtime environments, making it easier to share code with colleagues and collaborators.
- It helps transfer code from MASSIVE to your personal device.
- It helps you back up your own personal files.
You should complete the excellent course by Monash Data Fluency here: https://monashdatafluency.github.io/git-tutorial/.
As is often the case, there are a few changes to using git on MASSIVE. You can follow the instructions for Linux, but you do not have to install git. Instead, it can be accessed by opening terminal, and then running module load git
and pressing Enter
/Return
(you can instead press the tab
key twice to choose a particular version of git, but generally this is not required).
We suggest that you also install git on your local machine. You can also download the GitHub Desktop GUI on your local machine.
The other major change we suggest is related to 'Setup SSH Key' in the 'Installation' section. Instead of using that section, you can set up a Personal Access Token as described below.
Other than those few changes mentioned above, you should complete that tutorial. Then you should be ready to start saving and backing up your code with git and GitHub!
The easiest way to use git and GitHub are through the terminal. However, GitHub no longer uses passwords - instead, they use Personal Access Tokens. You can read about them here. We recommend creating a 'classic' personal access token - generally, fine-grained tokens are not necessary at this stage (in 2023).
- If you have already written code: navigate to the top folder in your project, open terminal, (use
module load git
if needed), and then usegit init
- it's that easy! - You should also back these up (publicly or privately) on GitHub. Log in to your GitHub page, to to the top right --> your repositories --> new repository. Then follow their instructions for creating a new repo from scratch, or for uploading code you have already written.
A reminder for some of the keys commands that you will often use. Consider using all of theses commands, in this order:
git push
git status
git add .
git commit -m "YOUR MESSAGE HERE"
git push
git status
git log
Have a look at the different areas of the git workflow here: https://ndpsoftware.com/git-cheatsheet.html#loc=index;
Once you start using git a few times, you'll start to have more and more questions about it. What do all of those commands above do? How do I manage different branches? Why doesn't someone else's code download properly? You can start by watching this fantastic video: https://www.youtube.com/watch?v=hZS96dwKvt0.
- 0.0 NSB Programming Courses (in ALPHA)
- 1.0 Working on the Cluster
- 2.0 Programming Languages
- 2.1 Python
- 2.1.1 Getting Set Up
- 2.1.2 Coding in Python
- 2.1.3 Applications of Python in Neuroimaging
- 2.2 MATLAB
- 2.3 R and RStudio
- 2.4 Programming Intro Exercises
- 2.5 git and GitHub
- 2.6 SLURM and Job Submission
- 2.1 Python
- 3.0 Neuroimaging Tools and Packages
- 3.1 BIDS
- 3.2 FreeSurfer
- 3.3 FSL
- 3.4 Connectome Workbench/wb_command
- 3.5 fMRIPrep
- 3.6 QSIPrep
- 3.7 MICApipe
- 3.8 MRIQC
- 4.0 Specialist Tools