Git on GitHub Exercise

Purpose:

Preparation

This is an partner exercise. Most of your homework should be done on private repos. For this simple exercise a public repo is fine.

Lesson

Your goal is to create a new project on GitHub and share it between two (or in some cases three) people. Remember from the slides there are two ways to set up a project. These instructions will briefly walk through those options. You should not treat this as a step-by-step tutorial that you walk through blindly. Try to think at each step about what's happening, on both local machines and also on GitHub.

Option 1

In this option, the repo is set up on GitHub. You will follow roughly the following steps.

Person A should:

  1. Create Repo. Sign into Github and create a new repository.
  2. Collaborators. Go to the Setting menu and add your partner(s) as collaborator (needed so they can push... if the repo is public, anyone can clone)
  3. Clone. On your machine:
  4. Sanity check.
  5. Unzip.
  6. Create project. You will need to let Eclipse know about your project.
  7. Import files. Now import the project.
  8. Commit. First commit to local repo:
  9. Push. In order to share these files, you'll need to push them onto GitHub:
  10. Sanity check. Take a look at the repo on GitHub. You should see your changes (spend a few minutes on this... getting familiar with the GitHub website will make things easier in the long run)

STOP. Take a minute now to think about what you just did (so you can repeat in the future with no instructions).

Option 2

In this option, the repo already exists on one person's machine. You will follow roughly the following steps.

Person A should:

  1. Extract.
  2. Create Eclipse project.
  3. Create repo.
  4. Collaborators.
  5. Local repo. On your machine, set up your local repository as you've been doing:
  6. Connect repo to GitHub. You need to use the remote command to set up a "link" between the repo in your workspace and the one on GitHub.
  7. Push. Now push your code onto GitHub:

STOP. Take a minute now to think about what you just did (so you can repeat in the future with no instructions).

Both options

Regardless of how the repo is set up, the steps for the second person should be similar. Person B should:

  1. Find repo. Sign onto github and find your partner's repo. You can type the name of the repo into the search (e.g., type in DrawPlay, you'll see lots of them). Or select Users in the search criteria, and type your partner's name.
  2. Clone. From Git Bash, cd to your workspace and clone the repo (git clone)
  3. Sanity check. cd into the project directory. Try a git status or maybe look at the log.
  4. Create Eclipse project. Bring your project into Eclipse. Make sure you have selected the workspace where you cloned the repo. Then do New->Java Project and use the name of the project you cloned. You should see the files.

Now that the project is set up on both machines, your goal is to practice pushing and pulling. Person B should:

Person A should now pull the changes, make some other changes, push. Alternate between Person A and Person B making changes. NOTE: Be careful not to make conflicting changes. As long as each person does a pull before writing any code, this should not be an issue.

Each person should do at least 3 changes/pushes. To develop good habits, every commit should include a meaningful comment (e.g., "Changed the ear color to purple" not "Updated the code").

Submit

Create a .txt file of your git log (remember: git log > log.txt) and submit on BB. As always, one submission per pair, and be sure to put your partner's name in the BB comments.

More practice

Note that you can practice these steps on your own, by creating different workspaces/repos/etc. Try it!