A Simple Tutorial

The goal of this tutorial is to give students hands-on experience in dealing with three of the most common aspects of Git - writing, staging and committing code, resolving merge conflicts, and opening pull requests.

Staging and Committing Code

  1. Create a fork of our git-learning repository to your account on GitHub.

  2. Open up a Git-enabled terminal, and clone the fork you've created to your computer.

  3. Change directory into git-learning.

  4. Edit the HelloWorld.java file, and replace "Hello, Conflicts!" with another phrase of your choice.

  5. Stage and commit HelloWorld.java.

Dealing with Merge Conflicts

Once everyone has changed code and committed, one of the programming leads will push a commit that will cause a merge conflict to the Spartronics repository. Merge conflicts are incredibly common when working collaboratively, and learning how to resolve them is an important skill.

  1. Make sure you're in the git-learning directory, and pull from upstream (git pull upstream master).

  2. You should be alerted of merge conflicts - edit the offending file, and resolve them manually.

  3. Stage and commit your merge-resolved HelloWorld.java file.

Opening Pull Requests

Now that you've dealt with your merge conflicts, the next step is to get your changes into upstream - the Spartronics organization's copy of git-learning. In a usual season, your code will also be reviewed by the subteam leads and mentors you're working with, and implement feedback accordingly.

  1. Make sure you're in the git-learning directory, and push your commits to your fork.

  2. Navigate to the Spartronics4915 git-learning repository, and open a pull request from your fork.

  3. Request review from one of the programming leads from the right sidebar.

  4. Submit your pull request, and you're done!

Last updated