Homework 5: Go Git and Fetch the Remote

This homework is due 2/21 at 11:59pm. Written answers should be submitted in an <ANDREWID>.txt file to Autolab.

  1. Create a new git repository somewhere in your filesystem, and configure a remote (called whatever you want, it doesn't matter to me) with the remote URL andrewID@unix.andrew.cmu.edu:/afs/andrew/course/98/174/public/hw5repo.

    • What command did you use to configure the remote?
    • Instead of creating a new git repository and configuring it with this remote, I could have asked you to git clone the repo from afs. If you had done so, what would the output of git remote -v be?

  2. Run git fetch remotename (substituting your remote name for remotename).

    • Did anything appear in your working directory? Why?
    • Update your local master branch with the remote one, and give the command you used to do so.
    • Your working directory should have been updated. You should check that. That means the master branch was updated on the remote. But it's possible that when we ran git fetch, we fetched other branches as well! How could we (i.e. what command could we use) find all the branches we may have gotten from the remote?
    • Run python3 hw5.py and you'll be prompted for your Andrew ID. The program will output a file that is unique to you, and this is how we'll track if you did the homework, so don't change anything about it.
    • To simulate collaboration, there is also a file that already exists called everyone.txt. You are going to commit both your unique file and make changes to at least 3 non-consecutive lines in everyone.txt on a separate branch with the same name as your Andrew ID. After, merge in your branch to master, and push both your branch and the commits on master.
    • NOTE: do not delete anyone else's content along the way. This means that you will have merge conflicts (how exciting, right?), and you will have to resolve them carefully when merging into master.

  3. In lecture, I was careful to explain the two-step procedure of using git fetch and git merge remotename/branchname to get commits from a remote. When would this be a good idea as opposed to simply doing git pull remotename branchname? Briefly discuss remote-tracking branches and their relevance in your answer.