We will be using the git version control system this semester, but this is a relatively new addition to CSC 161.
You won’t need to submit anything from this lab, but if you run into issues with any of the steps in this section please let the instructor know so we can troubleshoot the git setup for this course.
Make sure every member of your lab group completes this section before our next class.
First, you’ll need to sign in to the Gitea server we’re using for this course. Open https://git.cs.grinnell.edu in a new tab and click the Sign In button in the upper right. On the sign in page, click the Sign in with GrinCo-AAD at the bottom of the form. This may take you to a Microsoft sign-in page if you haven’t used your college account on MathLAN recently.
Once you finish logging in with your Grinnell account you should see a form filled in with your account information. You will need to change your username from the default value; please set it to your Grinnell account id (your email address without the “@grinnell.edu”).
Please make sure your account uses your Grinnell email address, which should be the default setting. We use your email address to set up repositories for your homework assignments, so using anything other than your Grinnell email could cause problems when homework assignments are released.
Submit the form to finish creating your account on the git server.
Next, we’re going to need to access the Gitea server using the command-line git tool, which requires us to set a password for your account.
Click the square icon in the upper right corner of the page;
this will be a randomly-selected icon for your account (for example, my account uses this icon:
).
Then select the Settings option from the drop-down menu.
On the settings page, click the Account section on the left side of the page. You should see a pair of fields that allow you to set a password on your account. Fill these in with a new password (do not reuse your Grinnell College account password!) and save your changes. You’ll use this password any time you access the git server from the terminal, but you can still log in via the web browser using your Grinnell College account.
You should now be able to access Gitea from the command line. To test this, you will clone a test repository from Gitea and make a test commit. Open the repository on Gitea at https://git.cs.grinnell.edu/csc161/git-test. You should see some information about the repository and a list of files.
This repository does not belong to you so you can’t change it, but you can create a copy of it (a fork in typical git terminology) where you are able to make edits.
Click the Fork button in the upper right, which should take you to a form titled New Repository Fork.
Leave all the settings at their default options and click the Fork Repository button.
This should take you to your own copy of the repository at https://git.cs.grinnell.edu/YOUR_USERNAME/git-test instead of the original repository linked above.
Now that you have a copy of the repository, we’re going to clone it to the MathLAN computer so you can edit it. There is a text field on the right just above the list of files, next to a set of buttons labeled HTTPS and SSH. Make sure the HTTPS option is selected and then copy the text in the text field, which should be “https://git.cs.grinnell.edu/YOUR_USERNAME/git-test.git”.
Next, open a terminal and run these commands to go to your labs directory and clone the repository fork you just created.
Note: you should not type the $ character into the terminal.
We use this character to mark a line of input and distinguish it from terminal output.
$ cd ~/csc161/labs
$ git clone PASTE_COPIED_TEXT_HERE
You should be prompted for your git username and password.
Enter the username and password you set when creating this account earlier.
Once the git clone command has completed successfully, we’re going to use the terminal to move into the cloned repository and edit it with Visual Studio Code:
$ cd git-test
$ code .
At this point you should see Visual Studio Code open, and the file message.txt should be listed in the file browser on the left.
Open the file, add a short message to the bottom of the file, and save it.
The file is modified, but the changes have not been stored in the git repository yet.
You can see a list of changed files by running this command in the terminal:
$ git status
Next, we’re going to switch back to the terminal to commit your changes by running the command below. You’ll likely see a prompt to edit your email address or name; follow the printed instructions to update this information.
$ git commit -a -m "Edited message"
Once the commit succeeds, running git status again should show no pending changes.
At this point, your edited message is stored in the copy of the repository you cloned to MathLAN.
It isn’t hosted on the git server yet, so you’ll need to “push” it to the git server.
To do that, run this command in the terminal:
$ git push
If you see any errors, raise your hand so a mentor or instructor can help you resolve the issue. The most common issue is a permission error, which probably means you cloned the original repository (where you do not have write access) instead of your fork.
Once the push has succeeded, go back to your forked repository in the web browser and make sure your updated message.txt is there.
If anything has gone wrong, raise your hand and a mentor or instructor can help you troubleshoot.
Now that one of you has completed these steps, log out of MathLAN and let the other group member(s) follow the same process. Every student in the course should set up Gitea and SSH access to make sure you are ready for our first git-based lab.