Homework 3: Checkout dat commit

This homework is due 2/7 at 11:59:59 p.m. You should combine all of your responses in a SINGLE .txt file named ANDREWID.txt and submit it at this Dropbox File Request link.

  1. What's the result of typing git commit with a Git repository in the state below? What files are in the working directory and what files are in the staging area? What about files in public/javascripts?

    A git status screenshot

  2. After a long vacation in Bermuda, Charlie returns to work on his project but discovers that someone has deleted all the files in his project with rm -rf *! Fortunately, the unknown adversary didn't realize Charlie followed good software practices and was using version control with git, so they forgot to delete the .git directory and did not run any git commands.

    1. Describe in words what the output would generally look like if Charlie runs git status.
    2. Give a command or a series of commands that would restore Charlie's project from the last commit (HEAD).
  3. After reading StackOverflow, Lucas decides that the correct way to make commits in git is to do git add .. Upon running git status, he discovers that as a result, he's staged the following files that he doesn't want to include in his next commit: .DS_Store, npm-debug.log, passwords.txt, mydiary.txt. Advise Lucas (1) what to do to fix the immediate problem and also (2) two ways that he could do specifically to prevent this from happening in the future (saying "don't trust everything you read on StackOverflow" is not sufficient).

  4. After editing a source file for a few days, Ana decides that she likes the version she had a few days ago better than what she has now. She now wishes to replace the current version of the file with that previous version. Ana doesn't remember the short hash of the most recent commit the previous version was last part of. Practically speaking, what would Ana have to do to find this out?

  5. A git repo containing the files A, B, C, D, E, and F is in the following state:

The previous state of the git repo

List a series of git commands that would cause git status to return this instead:

The final state of the git repo

Remember, git keeps track of changes within files, so you won't be able to just create empty files.