Group session July 1st


Let’s get back into using the terminal (Command Line Interface) a little.

With just a few commands you can create a version-controlled history of your code!




The Legend of Zelda 1986

You gotta save the changes to the file. You’ll do it (hopefully) – after every complete bit of code you write so you can see your changes in the browser, right? It should be second nature to save or save and refresh very often as you’re working.

But saving your file essentially overwrites your previous file. There’s only one file. Every time you “save,” you rewrite the text in that file to disk and blow away whatever was there before.

For example, early video games just had one slot to save your game. You either saved or you didn’t.

Committing to version control

The Legend of Zelda: Breath of the Wild 2017

Committing to version control will take the current state of your repo (all the associated files / and not just the file you hit save on last) and save that version of your codebase into the commit history. You will commit this snapshot of your files to a long-lived history of your saved states. This way, you can return to any of them later and see which files were added, removed, and changed over time.

With the video game example, nowadays, most games save hundreds if not thousands of spots on your journey so that you can have a history and possibly return to one of those past saved states.

Committing your codebase changes to Git isn’t the same as saving the file as you work. You couldn’t be expected to commit to Git repository version history whenever you wanted to save your file and see the updates in the browser. Commit your code whenever you have a meaningful bit of cohesive progress. You’ll want it to make sense when looking back over the history. And these things will make more practical sense when we start using them on team projects.

Take notes

Write down any critical concepts and any of the commands – in order of importance. Try to create your own “How-to.”

(The commands are all listed out below)

Command line recap

There are some commands you’ll need. Remember these?

  1. Terminal

    Print Working Directory


    Prints the current working directory you’re in.

  2. Terminal


    This will list out everything in your current directory.

  3. Terminal Command

    Change directory

    cd directory/path

    This will change your current directory to the provided path.

  4. Terminal

    Make Directory

    mkdir folder-name

    Makes a directory (aka folder) inside of whatever directory you are currently in.

Git commands

Here we go.

These are the commands you’ll need for today. Did we miss any?

  1. Terminal

    git version

    git --version

    Checks which version of Git you have. Also useful to check and see if you have Git installed at all.

    (If you don’t have it installed already, it should prompt you to install it)

  2. Terminal

    git init

    git init

    Initialize your current directory as a git repository.

  3. Terminal

    Change name of branch

    git branch -m nameofbranch

    Changes the name of your current branch. “main” is the current convention being used in 2022, so if your branch is initialized with a name other than “main” you can change it by using the command: git branch -m main.

  4. Terminal

    Check status of git repo

    git status

    Checks the current status of your git repository. Any changes to the folder will be shown.

  5. Terminal

    Add changes to staging area

    git add file-path/filename.extension

    This will add any of the changes on the file to the staging area.

  6. Terminal

    Commit files

    git commit --message "commit message here"

    This will commit any of the changes of your files with the associated message. You can also use the short-hand -m instead of --message.

  7. Terminal

    Check git commit history

    git log

    Display all past commits.

Some global settings

You’ll probably want to do these things at some point, but don’t get too tripped up by them today. If you get tripped up, give us a call and let’s go over it.

  1. Terminal

    Configure git user

    git config --global "username here"
    git config --global

    These two commands will configure your username and email address for all of your commits.

  2. Terminal

    Change default initial branch name globally

    git config --global init.defaultBranch nameofbranch

    Whatever branch name you chose when entering this command will be the name of the initial branch whenever you initialize a git repository.

Group session July 1st