Week 3 exercises
In this exercise, you will primarily be practicing your Git skills. Some tips:
- Keep checking the status of your repository (repo) with
git status
before and after nearly all other Git commands that you issue. This will help prevent mistakes, and will also help you understand Git better. - You won’t be doing anything new relative to what we did in class, and you can refer to those pages to see which commands and options you need to use.
1 Exercise
Local Git workflow
Create a new directory at OSC for these exercises, and move there.
For example,/fs/ess/PAS2700/users/$USER/week03/exercises
.Load the OSC Git module.
Don’t forget to do this, or you will be working with a much older version of Git.Initialize a local Git repository inside your new directory.
Create a README file in Markdown format.
The file should be namedREADME.md
, and for now, just contain a header saying that this is a repository for your exercises.Stage and then commit the README file with an appropriate commit message.
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.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.Update the
README.md
file.
Briefly describe the current contents of your repo now that you actually have some contents.Stage and commit the updated README file.
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.
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.Push your local repo to the online one you just created.
When you’re done, click theCode
button, and admire the nicely rendered README on the front page of your Github repo.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
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
Load the OSC Git module.
module load git/2.39.0
Initialize a local Git repository inside your new directory.
git init
Create a README file in Markdown format.
echo "# This dir is for the week3 exercises on Git" > README.md
Stage and then commit the README file with an appropriate commit message.
git add README.md git commit -m "Added a README file"
Create a second Markdown file with some more contents.
git_notes.md
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"
Update the
README.md
file.echo "Added a file with notes on Git" >> README.md
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"
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"
Create a GitHub repository.
See the lecture page.
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
Open a GitHub Issue.
See the lecture page.
Footnotes
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.↩︎