Collaborative git

From 22118
Jump to navigation Jump to search
Previous: Solo git Next: Functions, namespace, memory management

Required course material for the lesson

Powerpoint: Git
Optional - do you want to know more
Online: Coderefinery's introduction to git This is one of many git resources on the net.
Online: Markdown guide
Online: CI/CD - Continuous Integration and Continuous Delivery. It’s a DevOps practice used with GitHub/GitLab.
Resource: Example code - parsing command line options

Subjects covered

  • GitHub - inviting people to your repo
  • Git - branching, merging

Exercises to be handed in

Do the exercises in Python where applicable. Use git to track changes. Make one program per exercise (if relevant). Commit at least once per solved exercise - more often if you feel it relevant. At the end push everything to GitHub or more frequently if that is your pleasure - backup is nice. You gather all exercises into one file and hand that in on DTU Learn, hint cat in Unix. This is going to be the way we operate for large parts of the course.

Create a new private repository for your collaborative exercises for this single lesson on GitHub as described in the powerpoint. You can choose whatever name you like for the repository. Form a little group, preferably a group of two, but max three if a person is left out. Invite your fellow group member(s) to your repository. You are to "share" repositories.
A less exciting alternative to forming a small group, is to create two local repos of your GitHub repository as shown in the powerpoint. You will then have to pretend to be two persons working together. However, you will have an opportunity to test more things with git and how it works as you have full control.

Generally the hand-in to each exercise is the program you made/fixed/updated, plus the git commands you used to manage the repo. This can be be made in one file with comments.

  1. Copy exercise 9 from last week into your new repository and introduce an error in the exercise. Make it a real algorithm error, not just a syntax error.

  2. Now switch with the other person: Download his/hers repo, fix the error, push it back to the repo.

  1. First read and understand the Example code - parsing command line options. Now you have to make a program that can work with options. As more options are going to be added as the exercises progresses, better be smart and systematic about it from the beginning. The file input to this program will always be a tab-separated file, like ex1.dat. Make a program stat.py which takes a file name from the command line. There may be an option '-c <positiveinteger>' that denotes a column name in the file. The usage is therefore 'stat.py [-c] <filename>'
    If there IS an option -c the program should just read all the numbers in specified column (the number after -c option) into a list. If there is NO -c option, the program should read all numbers in all columns into a list - the order does not matter. There is no output (yet). Push to your repo.


  2. Switch to your partners repo. You now must add an option and a function to the program to his/hers program. The option is '-a' and the function should calculate the average of the numbers in a list. When using option '-a' the program should print the average of the list. Push the repo at least once when done or more often.
  3. Switch back to your own repo. Pull so you know it is updated.

Exercises for extra practice