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
Create a fork of our git-learning repository to your account on GitHub.
Open up a Git-enabled terminal, and clone the fork you've created to your computer.
Change directory into git-learning.
Edit the
HelloWorld.java
file, and replace"Hello, Conflicts!"
with another phrase of your choice.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.
Make sure you're in the git-learning directory, and pull from upstream (
git pull upstream master
).You should be alerted of merge conflicts - edit the offending file, and resolve them manually.
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.
Make sure you're in the git-learning directory, and push your commits to your fork.
Navigate to the Spartronics4915 git-learning repository, and open a pull request from your fork.
Request review from one of the programming leads from the right sidebar.
Submit your pull request, and you're done!
Last updated