Exercises

Exercise 1 - Choosing a Commit Message:

Which of the following commit messages would be most appropriate for the last commit made to git.txt?

  1. “Changes”

  2. “Added line ‘Torvalds said "I'm an egotistical bastard, and I name all my projects after myself. First 'Linux', now 'git'.""

  3. “how git was named--citation from Torvalds”

Exercise 2 - Committing to Git

Which command(s) below would save the changes of myfile.txt to my local Git repository?

  1. git commit -m "my recent changes"

  2. git init myfile.txt
    git commit -m "my recent changes"
  3. git add myfile.txt
    git commit -m "my recent changes"
  4. git commit -m myfile.txt "my recent changes"

Exercise 3 - Committing Multiple Files

The staging area can hold changes from any number of files that you want to commit as a single snapshot.

  1. Add some text to git.txt noting your decision to consider use git to help your work

  2. Create a new file I_love_git.txt with your initial thoughts about git

  3. Add changes from both files to the staging area, and commit those changes.

Exercise 4

bio Repository

  • Create a new Git repository on your computer called bio.

  • Write a two-line biography for yourself in a file called me.txt, commit your changes

  • Modify one line, add a third line

  • Display the differences between its updated state and its original state

Last updated

Massachusetts Institute of Technology