Mediascripting on the Web (CSC 195 2014F) : Assignments

Assignment: Exploring Git


This assignment gives you a chance to explore basic use of Git and GitHub.

Reference

git clone REPO

Make a copy of a repository. A typical repository address is https://github.com/Grinnell-CSC195/hw1.

git add FILE

This can do one of two things. If FILE is not in the repository, it adds it to the repository. If FILE is already in the repository, it marks it as being part of the current set of files to be committed. (Often, you only want to commit only a subset of the files you've modified, so you use git add on each of those.)

git status

Get the status of your repository. What files have been modified? Which are staged for commit? Which are just new?

git commit

Commits all of the files you're added. Typically, pops up an editor. If vi pops up, use i to switch to insert mode, type the text for the commit, and then type the escape key to get out of insert mode. Then, type :wq to write the file and quit vi.

git commit -m "MESSAGE"

Commits the files you've added, using the given message. (A nice way to avoid the editor.)

git log | less

Shows a log of the changes that have been made. (less lets you page through those changes.)

git push

Send your commits to the primary repository.

git pull

Grab other people's commits from the primary repository.

Preparation

  1. If you have not already done so, set up a GitHub account and send me an email message telling me about the account.

  2. Find a partner so that you can do this at the same time. You are working with a partner so that you can see conflicts and how to resolve those conflicts. Each of you should do the following instructions on your own account.

Assignment

  1. Clone the repository at https://github.com/Grinnell-CSC195/hw1.

  2. Add a file to the participants directory that describes you.

  3. Use git add to add that file to the repository.

  4. Use git commit to commit your change. Use a meaningful message like "Added information about YOUR NAME HERE."

  5. Use git push to send your change to the primary repository.

  6. Look online to see if your change has been pushed.

  7. Wait until your partner has pushed their update. Then use git pull to get their change into your repository. Verify that you have the new file.

  8. Use git log or git log | less to see a list of changes to the repository.

  9. Edit the file participants.md to add your name. Then add the file, commit it, and push it.

  10. Whoever tries to push the file first will likely succeed. Whoever tries to push the file second will likely get an error message. Figure out how to resolve the error message.

  11. In the code directory, there is a program that lists the members of this class. Update participants.c so that it prints your name, too. (Follow the pattern of the file.) Make sure that your program works by typing make and then ./participants. Then, add the file, commit it, and push it.

  12. Deal with any conflicts that have arisen and commit the result.

For those with extra time

If you want to learn more about Git, that would be great. If you do learn more about Git, please update tips.md with anything useful you've learned.

Some things that may be useful: Tagging commits, Branches, Comparing versions (diff), Standard work habits

Submitting your homework

Since your work is on GitHub, I can tell that you've turned it in. It even has a convenient time stamp.

Copyright (c) 2014 Samuel A. Rebelsky.

Creative Commons License

This work is licensed under a Creative Commons Attribution 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by/3.0/ or send a letter to Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA.