Prep 11: Regular Expressions and Git

  1. ReadLearn to use regular expressions and "git" setup...
  2. Due: 9am on 28 Oct.

For this prep, you will complete part of the RegexLearn tutorial and configure Git.

Regular Expressions

Regular expressions are a powerful tool for parsing text, performing advanced find-and-replace, and input validation!

RegexLearn is a helpful exercise that takes you through the basics of using RegExes. Complete parts 1-44 of the Regex101 tutorial (don’t worry, it’s actually pretty quick).

“Git” Setup

For next week’s labs, you will need to have Git installed and configured with an SSH key. We also recommend you use a command-line/terminal instead of relying on VS Code or a GUI, as you will need it for the labs.

“Git” an SSH Key

The first thing you need to set up is an SSH key. This allows your computer and GitHub to communicate securely:

  1. If you already have an SSH key and have added it to GitHub, you may skip this section.
  2. Otherwise, open Terminal or Git Bash (on Windows) and follow the steps in the GitHub documentation:
  3. Now, test your ssh key:
    • Testing your SSH connection
      • On Windows, you may need to run ssh-add <PATH_TO_YOUR_PRIVATE_KEY_FILE> in both PowerShell and Git Bash to make this test work!
  4. You can also try cloning a private repository on GitHub to test:
    • git clone git@github.com:PATH/TO-PRIVATE-REPO.git

“Git” the Config Set Up

You’ll also want to make sure your username and email are configured for Git. In a terminal (or Git Bash), run:

  1. git config --global user.name "<YOUR_NAME>", replacing <YOUR_NAME> with your full name.
  2. git config --global user.email "<YOUR_EMAIL>", replacing <YOUR_EMAIL> with your email address

“Git” Acquainted with Commands

Familiarize yourself with the Git cheat sheet (you may want to print it out): Git Cheat Sheet

Focus on the following sections:

  • 02 Starting a project
  • 03 Day-to-day work
  • 08 Reverting changes
  • 09 Synchronizing repositories

Your workflow will typically be:

# *** Make changes to your code ***

# See what files have been changed
git status

# Stage all files OR specific files
git add .  OR  git add file1.txt file2.txt ...

# Commit (make a "snapshot") of the staged changes
git commit -m "Commit message here."

# Retrieve any updates from the server (remote repository)
git pull

# *** Fix merge conflicts, if any ***

# Send your updates to the server (remote repository)
git push