CompSci 308
Spring 2024
Advanced Software Design and Implementation

Practice Exercise: Recovering from Mistakes in GIT

No matter how experienced you become with GIT, at some point you will make a mistake an commit or push something you do not want in the repository. Certainly, making smaller commits and paying attention when you commit will always be the first and best defense against mistakes (as well as never using git add .).

Resources

Experiment with Mistakes

We recommend using these two GIT commands before all of your commits to ensure you know exactly what is being changed:

However, once you have committed a mistake (pun intended), it is useful to be able to perform an "undo" — sometimes it will be possible to simply update the last action, but sometimes it may require creating a new commit that over writes previous changes. As long as the mistake is fixed, the history you leave is less of a concern for this course. Some GIT commands that will be useful include:

This humorous site also has more details about each command, including different options for each.

Each person should practice at least the following scenarios on your project repository (where you have some interesting commits to work with) to practice making and fixing GIT mistakes: