Skip to content

aernesto/ExampleGitExercise

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Three Big Reasons to Use Git

Version-Control Systems like Git and their associated online platforms such as GitHub are essential because:

  1. It is easy to get Open Source code written by others
  2. It is easy to share code (open source or not) with others
  3. It is great to keep track of the history of your project

This Repo

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.

Code development exercise

Try to perform the sequence of steps below:

  1. create a function myfunc that takes no argument and displays the number 38 to the screen (or at the console).
  2. create a script called myscript that calls myfunc once.
  3. share the script and the function with collaborator 1.
  4. Enhance both myfunc and myscript so that:
  • myfunc now takes a single integer as argument and displays it to the screen
  • myscript calls myfunc 5 consecutive times with successive arguments 1, 2, 3, 4, 5.
  1. you share the enhanced myfunc and myscript with collaborator 2.
  2. collaborator 1 gets back to you and tells you that myfunc should really take 1 integer as argument (just as the enhancement made) but myscript should call myfunc twice with successive args 33, 34. You bring the modifications and share the appropriate function and script with collaborator 1.
  3. collaborator 2 gets back to you and tells you that things look okay, except for the fact that myfunc really should subtract 2 from its argument before displaying the result to the screen. You implement the changes and share with them the latest files.
  4. 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 myfunc three 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.
  5. etc.

Solution

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)

Resources

Advice

Use Git from day 1 on all your coding projects!!!!

About

Example use case for git and GitHub

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages