Graded Assignment I: Shell, Markdown, and Git


Introduction

In this assignment, you will primarily be practicing your Git skills. You will also show that you can write in Markdown and can write a fo loop to rename files.

The instructions below will take you through it step-by-step. All of the the steps involve things that we have gone through in class and/or that you have practiced with in last week’s exercises.

Grading information:

Some general hints:


Part I – Create a new Git repo

  1. Create a new directory at OSC.
  1. Load the OSC git module.
    Don’t forget to do this, or you will be working with a much older version of Git.

  2. Initialize a local Git repository inside your new directory. [0.5]

  3. Create a README file in Markdown format. [0.5]
    The file should be named README.md, and for now, just contain a header saying that this is a repository for your assignment.

  4. Stage and then commit the README file. [0.5]
    Include an appropriate commit message.

Part II – Add some Markdown content

  1. Create a second Markdown file with some more contents. [1.5]

    This file can have any name you want, and you can also choose what you want to write about.

    Use of a good variety of Markdown syntax, as discussed and practiced in week 2: headers, lists, hyperlinks, and so on. (You’ll have to include some inline code and a code block later on, so you may or may not choose to use those now.) Also, make sure to read the next step before you finish writing.

    As long as you are not writing minimalistic dummy text without any meaning (like “Item 1, Item 2”), you will not be graded for what you are writing about, so feel free to pick something you like – and don’t worry about the details.

    (If you’re not feeling inspired, here are some suggestions: lecture and reading notes for this week; a table of Unix and/or Git commands that we’ve covered; things that you so far find challenging or interesting about Git; how computational skills may help you with your research.)

Hints

In VS Code, open the Markdown preview on the side, so you can experiment and see whether your formatting is working the way you intend.

  1. Create at least two commits while you work on the Markdown file. [0.5]
    Try to break your progress up into logical units that can be summarized with a descriptive commit message.
Hints

  1. Update the README.md file. [0.5]
    Briefly describe the current contents of your repo now that you actually have some contents.

  2. Stage and commit the updated README file. [0.5]

Part III – Add some “data” files

  1. Create a directory with dummy data files. [0.5]
    Create a directory called data and inside this directory, create 100 empty files with a single touch command and at least one brace expansion (e.g. for samples numbered 1-100, or 20 samples for 5 treatments). Give the files the extension .txt.

  2. Stage and commit the data directory and its contents. [0.5]
    As always, include a descriptive message with your commit.

Part IV – Renaming files on a new branch

As it turns out, there was a miscommunication, and and all the “data” files will have to be renamed. You realize that this is risky business, and you don’t want to lose any data.

It occurs to you that one good way of going about this is creating a new Git branch and performing the renaming task on that branch. Then, if anything goes wrong, it will be easy to go back: you can just switch back to the master branch.
(Note that there are many other ways of undoing and going back in Git, but this one is perhaps conceptually the easiest, and safe.)

  1. Go to a new branch. [0.5]
    Create a new branch called rename-data-files or something similar, and move to the new branch. (Also, check whether this worked.)

  2. Write a for loop to rename the files. [1.5]
    You can keep it as simple as switching the file extension to .csv, or do something more elaborate if you want.

    Because these files are being tracked by Git, recall that there is a Git-friendly modification to the command to rename files: use that in the loop.

Hints

  1. Commit the changes made by the renaming operation.

  2. Merge into the master branch. [0.5]
    With the files successfully renamed, go back to the master branch.
    Then, merge the rename-data-files branch into the master branch.
    (Optionally, remove the rename-data-files branch, since you will no longer need it.)

  3. Update the README file.
    In the README file, describe what you did, including some inline code formatting, and put the code for the for loop in a code block.
    (No, the repo doesn’t really make sense as a cohesive unit anymore, but that’s okay while we’re practicing. :) )

  4. Stage and commit the updated README file. [0.5]

Part V – Create and sync an online version of the repo

Phew, those were a lot of commits! Let’s share all of this work with the world.

  1. Create a Github repository. [0.5]
    Go to https://github.com, sign in, and create a new repository.

    • It’s a good idea to give it the same name as your local repo, but these names don’t have to match.
    • You want to create an empty GitHub repository, because you will upload all the contents from your local repo: therefore, don’t check any of the boxes to create files like a README.
  2. Push your local repo online. [0.5]
    With your repo created, follow the instructions that Github now gives you, under the heading “…or push an existing repository from the command line”.

    These instructions will comprise three commands: git remote add to add the “remote” (online) connection, git branch to rename the default branch from master to main, and git push to actually “push” (upload) your local repo.

    When you’re done, click the Code button, and admire the nicely rendered README on the front page of your Github repo.

Hints

Assuming that you’re using SSH authentication, which you should have set up in this week’s ungraded assignment, make sure you use the SSH link type: starting with git@github.com rather than HTTPS.

  1. Create an issue to mark that you’re done! [0.5]
    Find the “Issues” tab for your repo on Github:

    In the Issues tab, click the green button New Issue to open a new issue for you repo.

    Give it a title like “I finished my assignment”, and in the issue text, tag @jelmerp. You can say, for instance, “Hey @jelmerp, can you please take a look at my repo?”.

Reuse

Text and figures are licensed under Creative Commons Attribution CC BY 4.0. The figures that have been reused from other sources don't fall under this license and can be recognized by a note in their caption: "Figure from ...".