Week 3 exercises



In this exercise, you will primarily be practicing your Git skills. Some tips:


1 Exercise

Local Git workflow

  1. Create a new directory at OSC for these exercises, and move there.
    For example, /fs/ess/PAS2700/users/$USER/week03/exercises.

  2. Load the OSC Git module.
    Don’t forget to do this, or you will be working with a much older version of Git.

  3. Initialize a local Git repository inside your new directory.

  4. Create a README file in Markdown format.
    The file should be named README.md, and for now, just contain a header saying that this is a repository for your exercises.

  5. Stage and then commit the README file with an appropriate commit message.

  6. Create a second Markdown file with some more contents.
    Name it as you like and in it, describe the basic Git workflow and commands with bullet points and headers1.

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

  8. Update the README.md file.
    Briefly describe the current contents of your repo now that you actually have some contents.

  9. Stage and commit the updated README file.

  10. Create a results directory with an empty file and make Git ignore this directory.
    Also, commit your .gitignore file.


Create and sync an online version of the repo

Phew, you made several commits! Time to share all this work with the world.

  1. Create a Github repository.
    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. Like in class, you want to create an empty GitHub repository, because you will upload all the contents from your local repo.

  2. Push your local repo to the online one you just created.
    When you’re done, click the Code button, and admire the nicely rendered README on the front page of your Github repo.

  3. Open a GitHub Issue
    As practice for when you need to do this for your Final Project submissions, open an Issue for your repo: in the Issues tab, click “New Issue”, and in the box where you can type your issue, tag me. For example:

    Hey @jelmerp, can you please take a look at my repo?


2 Solutions

  1. Create a new directory at OSC for these exercises, and move there.

    mkdir /fs/ess/PAS2700/users/$USER/week03/exercises
    cd /fs/ess/PAS2700/users/$USER/week03/exercises
  2. Load the OSC Git module.

    module load git/2.39.0
  3. Initialize a local Git repository inside your new directory.

    git init
  4. Create a README file in Markdown format.

    echo "# This dir is for the week3 exercises on Git" > README.md
  5. Stage and then commit the README file with an appropriate commit message.

    git add README.md
    git commit -m "Added a README file"
  6. Create a second Markdown file with some more contents.

    git_notes.md
  7. Create at least two commits while you work on the Markdown file.

    # Commit #1
    git add git_notes.md
    git commit -m "Started a document with notes on Git"
    
    # (Make changes to git_notes.md)
    
    # Commit #1
    git add git_notes.md
    git commit -m "Descriptive commit message #2"
  8. Update the README.md file.

    echo "Added a file with notes on Git" >> README.md
  9. Stage and commit the updated README file.

    git add README.md
    git commit -m "Added a description of the repo's contents to the README"
  10. Create a results dir and file, and make Git ignore this directory.

    # Create the dir and file that should be ignored
    mkdir results
    touch results/results.txt
    # Create a gitignore file with instructions to ignore the 'results' dir
    echo "results/" > .gitignore
    # Add and commit the .gitignore
    git add .gitignore
    git commit -m "Added a gitignore file"
  11. Create a GitHub repository.

    See the lecture page.

  12. Push your local repo to the online one you just created.

    # Step 1: Set up the connection to the remote repo
    # (replace <SSH-URL-to-repo> with your actual SSH (not HTTPS!) URL)
    git remote add origin <SSH-URL-to-repo>
    # Step 2: Push to remote
    git push -u origin main
  13. Open a GitHub Issue.

    See the lecture page.


Back to top

Footnotes

  1. Recall that in VS Code, you can open the Markdown preview on the side, so you can experiment and see whether your formatting is working the way you intend.↩︎