Midterm: Do you all git these puns?

Please write your answers to each question in a .txt file and submit it to the "Midterm" assignment on Autolab. Some questions will ask you to download and modify a git repository. For your answer to these questions, please submit a list of the git commands you used in order.

    1. Is git distributed or centralized? Justify your answer by briefly explaining the difference.

    2. Give an example of a bad commit message. Do not copy the one in the notes.

    3. Give an example of a good commit message. Do not copy the one in the notes.

  1. Download this repository here. You will see that the repository contains a single commit that added three files, and that the working directory and staging area are clean (no changes to stage or commit). WITHOUT making a commit, use git commands (of course, you'll have to edit some of the files too) to change the git repository so that the output of git status looks like below. For your answer to this question, list the git commands you used in order.

  2. Ilan finished question 2 of this midterm, made a commit, then modified and staged fileB. The output of git status now looks like this:

    Give a git command for each of the following cases that will achieve Ilan's goal:

    1. He regrets staging his changes to fileB and wishes to undo it so that his changes to fileB are still in the working directory, but are not staged.
    2. He wishes to undo the changes to fileC that are in the working directory (in other words, he wants to retrieve the version of fileC that was in a previous commit. Since you downloaded the repo for question 2, you should be able to find the commit hash for the initial commit, if you really need it).
  3. Make a directory on your computer, and initialize a new git repository INSIDE the directory. Your task is to make commits (and the associated branches) to this git repository so that the commit graph matches the graph below. I also show the output of git log --graph --abbrev-commit --decorate --all, because after you make these commits to match the graph, you should run this command and make sure it resembles mine. Make sure the two branches and HEAD end up at the correct commits.

  4. Clone the Git repository at <ANDREW_ID>@linux.andrew.cmu.edu:/afs/andrew.cmu.edu/course/98/174/public/midtermrepo. Notice that there are 3 branches if you print out all the branches on the remote. These all have changes I'd like to see included in one branch. To avoid conflicts between student submissions, you'll merge the branches into master on your computer, but then you'll create and push a new branch with the same name as your ANDREW ID. Merge the branches with lower numbers first.

    NOTE: When merging, always include the content of the commit you are merging into master instead of master's current changes, and make sure you aren't deleting the content of any other branches you have already merged in. This might mean that you'll have to manually combine resulting merge conflicts.

    HINT: Each branch has 1 modification and 1 addition. Some of these may be handled automatically and some may not be.

    Things you'll be "submitting" for this question:

    • A pushed branch named by ANDREW ID with all the branches merged in the correct order.
    • An explanation in your .txt file why the first branch that was merged used a fast-forward, and the others did not.