Setting up VS Code | CS 2113 Software Engineering - Fall 2021

Using VSCode with Git and Docker to Complete/Submit a programming Assignment

Before starting, you should have completed the VScode Setup Guide with Docker. This guide assume you have VScode and Docker Desktop installed, as well as the VSCode extension Remote Development Extension. Alternatively, your using the VScode with SSH setup. One or the other.

Did something go wrong? Check out the troubleshoot guide

  1. Accept the github classroom assignment and follow the link to the repository. For example, if you are working on Lab 1, after accepting the assignment, you’ll have a new repository named lab-1-username where username is your github username. My github username is adamaviv, so you will see that in the screenshots below.

  2. Copy the repository link by clicking the Code label

    Github Repo Link

    If you have setup an ssh key, use ssh, otherwise use HTTPS.

    To setup an ssh key, see this guide

  3. Open up a new window in VScode via File->New Window or ⌘⇧N / Ctrl⇧. Then click the explorer and then Clone Repository

    VScode New Window, Explore, Clone Repository

    If you don’t see an option to Clone Repository then you may not have git installed. Follow this link to install it for your computer.

  4. Enter the repo link in the command pallet.

    Enter repo link

  5. You will be prompted where to save the repo. Save it wherever you want, but I like to create a folder called git or vscode to save all my projects.

  6. Go ahead and open the repo in this window by selecting Open

    Open in this window

  7. Nearly all repos in our class will ship with a devcontainer which will prompt you to open the repo within a container as a volume or reopen the container. You should do this as a volume.

    Open in volume

    If you don’t see this step, you can skip it.

  8. After this, VScode will work a bit to launch the container. This can take awhile depending on if the container image was downloaded previously.

  9. Once complete, you’ll have your workspace ready to go and integrated terminal open.

    Init Complete

  10. Do your work. And once done, you need to commit your work. Start by clicking on the repo symbol

    Repo symbol

  11. Add the modified files (or new files) to be staged for commit by pressing the +

    add files to the commit

  12. Click the ✓ to perform the commit

  13. Finally, push your changes to github by clicking the ... at the top and selecting push

    Push changes

  14. Finally, finally, you should go back to github as a final check to make sure you pushed all your changes.

Using the git command line in the integrated terminal

You can also use the command line to do the git commands.

git add file.txt        #add a file to the commit
git commit -m "message" #perform the commit with the commit message
git push                #push the commit to github 

If you want to add all the files that have been modified and commit all at once, use the following

git commit -a -m "message" 

Having an issue with ssh?

If you find that your ssh key is not available in the container, you may need to add your private key to the ssh-agent.

VScode has a good guide explaining how to help with that

Asking you to set up your git profile?

If you’re getting a error saying you need to setup your name and email, then open the integrated terminal and type these two commands

   git config --global user.name "John Doe"
   git config --global user.email johndoe@example.com

Where John Doe is replaced with your name and johndoe@example.com is replaced with the email address you used to sign up to github