For this assignment, you must use your account on calgary.cs.washington.edu:

ssh [netid]@calgary.cs.washington.edu

From here, change into your cse374 directory by running the following:

cd cse374

Clone your own git repo

Caution

Make sure that you’ve completed Ex6 before continuing!

You should have already cloned your personal git repository in calgary, but if you haven’t you can do the following:

git clone git@gitlab.cs.washington.edu:cse374-24wi-students/cse374-24wi-[uw_net_id].git
cd cse374-24wi-[uw_net_id]

Caution

If you get an error saying “Permission denied (publickey)…”, then there is a problem with your GitLab configuration. Check to make sure you have your SSH key setup correctly, your private key is in your SSH directory (~/.ssh), and that you can view the repository through the website.

Set cse374-24wi-hw repo as an upstream remote

Now that you’ve navigated to your repository, you’ll need to set up a new remote to pull down the starter code. You can do so with the following:

git remote add upstream git@gitlab.cs.washington.edu:cse374-24wi-students/cse374-24wi-hw.git

Git will add the cse374-24wi-hw repository as an upstream remote to your repository.

The copy on your file system is a local copy, and the copy on GitLab is referred to as the origin remote copy. You can view a list of these remote links as follows:

git remote -v

See the documentation for more details on working with remotes for more information, but we’ll cover everything you need to know here.

Your final remote configuration should read like the following when it’s setup correctly (run git remote -v):

origin  git@gitlab.cs.washington.edu:cse374-24wi-students/cse374-24wi-[uw_net_id].git (fetch)
origin  git@gitlab.cs.washington.edu:cse374-24wi-students/cse374-24wi-[uw_net_id].git (push)
upstream        git@gitlab.cs.washington.edu:cse374-24wi-students/cse374-24wi-hw.git (fetch)
upstream        git@gitlab.cs.washington.edu:cse374-24wi-students/cse374-24wi-hw.git (push)

In this configuration, the origin (default) remote links to your repository where you’ll be pushing your individual submission. The upstream remote points to our repository where you’ll be pulling subsequent homework and bug fixes (more on this below).

Pull starter code from the upstream repo

You will need to pull updates from the cse374-24wi-hw repository to get the actual files for hw3, and then push it to your personal repository.

But first, we’ll tell git how we want to merge the files together when we run git pull. Run the following command:

git config pull.rebase false

This tells git to use the merge strategy rather than a rebase. Don’t worry about the difference here, we’ll always use the merge strategy in this class.

Now that we’ve added that configuration, run the following to fetch the starter code and push it to your personal repository:

git pull upstream main --allow-unrelated-histories --no-edit
git push

In the future, we will be releasing homework to the repository that you just added as an upstream remote. If you have made any changes to your own repository, commit them before proceeding to the git pull. Otherwise, the merge step might fail.

When you pull the code, Git may open a text editor to allow you to specify a merge commit message (it won’t here because we specified the --no-edit flag); you may leave this as the default. Note that these changes are merged locally, but we will eventually want to push them to the GitLab repository (git push).

Note

It’s possible that there aren’t any pending changes in the upstream repository for you to pull. If so, git will tell you that everything is up to date.

🎉 Congratulations! You have successfully set the cse374-24wi-hw repository as an upstream remote and pulled starter code from it into your own repository. Spend a few minutes getting familiar with the directory layout and file structure. Then, you can cd hw3 and start working on hw3!

Tip

Commit early and often! Any time you commit and push your local changes, they will appear in the GitLab repository. Since you’ll be submitting the homework to Gradescope via the GitLab repository, it’s important that you remember to push all of your changes!