Lab 0: Git Familiarization | CS 2113 Software Engineering - Spring 2021

Lab 0: Git Familiarization #

The goal of this lab is to get you more comfortable with using git. This lab is not worth any credit but still required. You must complete it in order to submit any future assignments.

Part 0: Creating a github account and installing software #

You are required to have a github account for this class.

If you do not have a github account #

Well, you need to sign up!

  1. Go to https://github.com/ and enter your info to “Sign up for GitHub”.
  2. Select a username and password – your username is your github id
    • For your github id, choose something tasteful. Your name with a hyphen, like firstname-lastname could be a good choice, but choose something you like and represents you.
    • Note that for job interviews, you may want to advertise your github id, so don’t choose something like youallsuxor
  3. Use an email address you have access to and check frequently. When there are issues/updates to your submissions, you’ll get an email. You may want to use your GW email address for this.

If you do have a github account #

Please go to your account and check the following items:

  1. You use an email address that you check often because you will get important notifications.

Download install git, gcc, Java, and the manpages #

While you will be able to complete many of the assignments for this class using an online IDE, like replit, you will find it useful to have a local development environment to complete your work, such as a virtual machine with Ubuntu linux installed (or installed on your computer directly). This will really help you get more familiar with Linux which will help you in your next classes.

Alternatively, you could also remotely access the SEAS Virtual Linux Lab, which will provide you a Linux installation in the browser. This system works surprising well and requires that you do not need to install any additional software.

Mac users #

(Note, once you install the command line tools for Xcode, you also get access to the gcc (really `clang) compiler, and can do all your C development there.)

Important: Mac users will not be able to run valgrind on their local machine and so must complete some of the labs / projects using a different method. I’d recommend using replit or a VM with Linux in these scenarios.

Ubuntu/Linux users #

Windows Users #

Windows users have a few options of installing git and command line tools.

  1. They can install ubuntu through the Windows Subsystem for Linux (WSL) and then follow the Ubuntu/Linux instructions (recommended)
  2. Create a virtual machine either with vmware or virtualbox to run ubuntu and then follow the Ubuntu/Linux instructions (also good and recommended)
  3. You could also use the SEAS Virtual Linux Lab (VLL), which provides you a full feature Linux system you can access through the browser. It has everything you need already installed. (also good)
  4. You can install Cygwin which is a unix environment for windows, similar to the WSL. (works ok)

Extras for git #

Setup an ssh-key for your github account. This is a huge time saver and much more secure than using a password. Check out this guide

You can also generate an access token, which you could (should!) use in place of a password when using git’s https access. Check out this guide

Install InteliJ #

For the second half of this class, when working with Java, we may find it useful to use a Java IDE. IntelliJ IDE is a professional level develop environment, which you can download for free under an educational license.

  1. Go to the application for jetbrains student license and complete it. It should be approved rather quickly (automatically)
  2. Create/Login to your account, and then under student license, proceed to download and install IntelliJ IDEA.
  3. Open it for the first time, and it should automatically find your Java install (if you’ve done the above steps)
  4. Try running and executing a HelloWorld program in Java.

Part 0 Requirements:

  1. Fill out the following form to show you’ve completed the items above
  2. Accept this assignment in github classroom: https://classroom.github.com/a/qE5uuDFT

Part 1: Checking out your github classroom assignment #

Now that you have a github account. The next part is to accept and assignment and join the class organization. Do so by clicking on the following link (or copy and pasting the url) below. Be sure your logged into the github account you created/updated previously.

Github Classroom Link: https://classroom.github.com/a/SOb-9HqF

Since this is the first assignment for the class, it will ask you to join the organization. When you do so, please be sure to use your REAL NAME and GW netid for associating with this class so that we can properly grade your assignments.

Following that, github will automatically fork/clone the assignment into a new repository entitled lab0-<username> in the cs2113-s21 github organization where <username> is replaced by your github ID. Navigate to it now.

You might find this youtube tutorial helpful for navigating github classroom submisions.

Requirement Part 1

  • Join the github classroom
  • Accept this lab-0 assignment

Part 2: Markdown and Updates on github #

Once you’ve accepted the assignment, navigate to the repository on github. On the repository webpage, you’ll find a README.md file. This extension .md indicates that it is formatted in markdown, which is a markup language, like HTML, that describes how to display text. That’s what I’m writing this in right now.

Click on README.md to open up that file.

Editing in Markdown on github #

For example, you can make text bold or italic by enclosing it *’s:

You can make code blocks by using three backticks `. The backtick is the key above the tab button on most keyboards.

backtick on the keyboard

For example, to include C code, you might type something like the left, to render something like the right. Note the c at the top to tell Markdown how to color highlight using C.

```c
int main(){
  printf("Hello, World!\n")
}
```
int main(){
  printf("Hello, World!\n")
}

You can find more about markdown from the github guide on markdown.

Part 2: Requirements

  1. Edit the README.md file for this lab on github by clicking “edit”
  2. Complete the instructions in there and commit your changes
  3. You should be able to see them page reformat on github
  4. Then edit the file survey.md (also in the repo) and answer the questions there.

Part 3: Using git on the command line #

In this part you are going to clone a copy of your repository to your local machine, make changes and push those changes back to github.

Cloning a repository #

First, a git repository is self contained representation of the history of edits to a group of files. You can clone that repository to multiple computers, which becomes your local copy.

In the therminal, to clone your repository you use the command:

git clone PATH-TO-REPO

The PATH-TO-REPO can either be a local path, on your file system, or a remote URL. In this case, we want a remote URL. To find that URL, on github on the lab repository, find the button that looks like   Code   and then click to copy the URL to your clipboard. And run git clone with PATH-TO-REPO replaced by your url. (You may be asked for your username and password for github.)

Now that you’ve downloaded a local copy, you should now change into that directory.

cd repo-name

You can use the ls (or list) command to show the contents of that directory, but most importantly, we want you to create a new file in that directory.

Using your favorite text editor (not Word!), create a new file called bio.txt and write into that a brief, three sentence biography of yourself. Whatever you want to say is fine.

Adding/Committing files to the repo #

The new file you created does not yet tracked by git. We can see that by checking the status of the repo.

$ git status
On branch main
Your branch is up to date with 'origin/main'.

Untracked files:
  (use "git add <file>..." to include in what will be committed)
	bio.txt

nothing added to commit but untracked files present (use "git add" to track)

We must then add bio.txt to the repo using add

git add bio.txt

Now when we check the status we see

$ git status
On branch main
Your branch is up to date with 'origin/main'.

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
	new file:   bio.txt

But, the file is not yet committed. The last step is to commit

$ git commit -m "Adding my bio to the repo"
[main 8876465] Adding my bio to the repo
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 bio.txt

The -m is the comitt message, which in this case is “Adding my bio to the repo”

Pushing your changes back to github #

You’re still not done yet! While your local copy of the repo is updated, the remote repo at github has not received these changes. We have to push those changes back to the origin (which is the github URL you copied from above).

git push

Doing a push is the same as submitting your work. We’ll always evaluate the last commit you pushed to github prior to the deadline.

Updating an existing file #

Now, update your bio.txt with one more sentence: “Thanks for all the fish!”

If you run git status you’ll see that bio.txt was marked as modified.

$ git status
On branch main
Your branch is up to date with 'origin/main'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   bio.txt

no changes added to commit (use "git add" and/or "git commit -a")

You’ll need to go through the motions of adding those modifications, committing the changes, and then pushing those to github.

git add bio.txt
git commit -m "update to my bio"
git push

Since you often always want to include all modifications to files, there is a short hand for add and commit all modifications using -a.

git commit -a -m "updating all modified files"

Part 3 Requirements:

  1. Follow the instructions above
  2. Make sure you have at least TWO commits on the bio.txt file by navigating to the bio.txt on github and clicking on history

Part 4: Github Issues #

We will be using Github issues for communicating about your assignments in this class. Let’s quickly practice creating an issue now. At the top bar of options on your repository, click on Issues, then click the green button New Issue.

Name your issue “Lab 0 Testing Issues” for the Title and then in the body, answer the following questions by copy pasting the below into the box. (Note that the issue box understands markdown, and you can also preview it.)

1. What time locally is it for you right now?
   > PUT YOUR ANSWER HERE (leave in > for a quote)
2. How many hours did you spend working on this lab
   > PUT YOUR ANSWER HERE (leave in > for a quote)
3. What is your favorite color?
   > PUT YOUR ANSWER HERE (leave in > for a quote)
4. What is your favorite ice cream flavor?
   > PUT YOUR ANSWER HERE (leave in > for a quote)
5. What is your favorite number? 
   > PUT YOUR ANSWER HERE (leave in > for a quote)

Then finally, at the bottom tag the teaching staff by adding @cs2113-s21/grading-staff

Part 4 Requirements:

  1. Follow the instructions above and open an issue
  2. Answer the questions and tag the teaching staff

Part 5: Replit #

For many of the github assignments in this class, you can use replit online IDE to develop, compile, and run your code. It provides good github integration. As an example, accept the following assignment in github classroom

https://classroom.github.com/a/6MyL2Nsd

Once you do so, open the assignment using the replit button. In it is a basic “Hello World” program in C. Edit this program to print out a new phrase, other than “Hello, world!”.

In the replit terminal, you can use git to commit this change, as well as the user interface on the left hand side of your screen.

Part 5 Requirements:

  1. Accept the assignment on github https://classroom.github.com/a/6MyL2Nsd
  2. Edit the hello world program in replit
  3. Push your changes back github either using the command line git interface or using the embedded GUI