Version-Control Systems like Git and their associated online platforms such as GitHub are essential because:
- It is easy to get Open Source code written by others
- It is easy to share code (open source or not) with others
- It is great to keep track of the history of your project
This repo shows how git and GitHub can address a specific minimalist use case. The goal is to simulate a minimal project development setup, in which sharing with 2 independent parties is needed.
Note: I use MATLAB here, but the whole exercise is doable in any language. I encourage you to do it in your favorite programing language.
Try to perform the sequence of steps below:
- create a function
myfuncthat takes no argument and displays the number 38 to the screen (or at the console). - create a script called
myscriptthat callsmyfunconce. - share the script and the function with collaborator 1.
- Enhance both
myfuncandmyscriptso that:
myfuncnow takes a single integer as argument and displays it to the screenmyscriptcallsmyfunc5 consecutive times with successive arguments 1, 2, 3, 4, 5.
- you share the enhanced
myfuncandmyscriptwith collaborator 2. - collaborator 1 gets back to you and tells you that
myfuncshould really take 1 integer as argument (just as the enhancement made) butmyscriptshould callmyfunctwice with successive args 33, 34. You bring the modifications and share the appropriate function and script with collaborator 1. - collaborator 2 gets back to you and tells you that things look okay, except for the fact that
myfuncreally should subtract 2 from its argument before displaying the result to the screen. You implement the changes and share with them the latest files. - At some big conference, you present a poster for which you used a slightly different version of the code, compared to what you last shared with collaborator 1. Namely, the script calls
myfuncthree times with arguments 66, 67, 87. You want to remember the exact version of the code used for this poster in case someone asks detailed questions about it. - etc.
The present repo solves the problem above by:
- assigning a specific branch to each collaboration
- assigning annotated tags (release versions) to every important commit (e.g. when sharing or for presentations)
- High-Level Intro to GitHub
- Configure git on your computer
- Use a Graphical User Interface (GUI) for Git if you wish. One possibility is GitHub Desktop, but there are many more.
- A good (some people might say better) alternative to GitHub is GitLab. It works in a very similar manner.
- This Student Developer Pack is invaluable.
- I find the MATLAB resources on git appalling, but there is still some important info there for MATLAB users.
Use Git from day 1 on all your coding projects!!!!