Using git

GitHub account

First, you will need to create a GitHub account here. If you already have one, you can use your existing account.

git installation

You will likely already have a command-line version of git installed on your machine. To check, open a folder in VS Code, display the integrated terminal, and type:

git --version

You should see a version number printing out. If you see that, git is already installed.

If you see an error that git is unrecognized, then you will need to install it. Go here to download and install the latest version.

Windows users may need to add the git.exe location to the system Path environment variables. Most likely, git.exe will be installed to C:\Program Files\Git\bin. Check this location, copy its address, and type “Environment variables” in the Windows search. Click “Environment Variables” and find “Path” under System variables. Click “Edit…”. Verify that C:\Program Files\Git\bin (or whatever your git location) is the last item listed. If it isn’t, add a new entry for C:\Program Files\Git\bin.

Clone class repository

On the first day of class, you will create your initial GitHub repository for CIS 200 and clone it to a “cis200repo” folder on your One Drive. You shouldn’t need to clone your class repository again after that unless you want to store it in a different location.

In the case that you DO want to re-clone your repository, go to your GitHub repository in a browser. Click the green “Code” button and then click the copy icon next to the URL name. This will copy the URL of your GitHub repository.

In a File Explorer, navigate to where you want to store your class work. Create a new folder called “cis200repo”. Right-click that new folder and select “Open with Code”.

Then open the Terminal within VS Code by selecting “Terminal->New Terminal”. The terminal should automatically display the empty cis200 folder you just created.

Clone your GitHub repository to your new, empty cis200 folder by typing in the terminal:

git clone {repository-url} ./

Where {repository-url} is the URL you copied from your GitHub repository (leave off the ``{and}when you insert your URL). The./` tells git to clone the repository to the current directory.

Adding, committing, pushing changes

I recommend that you add/commit/push your changes to GitHub every time you reach a stopping point in development, even if you’re not finished with the assignment. This will both ensure that you have a backup of your work as well as create a snapshot of your current progress that you can revert back to if you make other unwanted changes.

First, be sure that all your work is saved. All unsaved changes are ignored by git, and won’t be added to your remote repository (and by extension won’t be submitted as part of your assignment). Before adding/committing/pushing, be sure to save all your files (File-Save or Ctrl-S). Make sure none of the open file tabs have a solid circle next to the file name – this is an indication that they are unsaved.

Once everything is saved and you are ready to commit your changes, type the following in the integrated terminal:

git add .

This will add all changes to the current commit. Then type:

git commit -m "descriptive message"

to create a local commit, where “descriptive message” is replaced with a message describing your changes (you DO need to include the quotations). Finally, push your local commit to the current branch:

git push

If you go to your GitHub repository URL, you should see the latest changes.