How to restore your project to a previous commit

Restoring a Project

Moving back in time

Marc Frappier
3 min readMar 31, 2021


When we are working on a project, whether it be alone on with several collaborators, there might come a time when someone, somewhere messed up and it has already been committed. Never fear, as long as several commits have been made and pushed to the GitHub account repository, we can always revert to a previous working state.

While in the Git Bash terminal and in the current project directory, the following command will list all commits made so far:

Gt log command
Git log

Using the down-arrow key we can move further down the list. The information given includes a commit number specific to each commit, the author of the commit and the date and time the commit was made. Under all this is the description given to the commit. This is why it is important to document each commit with a description using the git commit -m “description here” command.

To get out of log mode, press Q for Quit.

log file

Now, if we still aren’t sure if the commit we see is the one we really need, there is a way to check it out before we make the decision to revert to that specific commit.

We can take the commit number, the really long one, and turn it into a branch which we can then check out in the Unity project. To do this, we would highlight the commit number we want, copy it and use the following command:

Make branch from commit number

Here, the branch name is optional but recommended, otherwise the branch will be named using the commit number.

By using git checkout -b, we both create the new branch and move into it at the same time.

creating a git branch from commit number

Once we are in that branch, if we go to the Unity project and refresh the page, we will be able to see if that is the commit we need. If it is then you can work on that branch and then commit it.

Reset master branch to a previous time

If you can’t find the commit you are looking for on the local machine, go to the GitHub repository and check out the commit list. Select the one you want and copy the commit number.

Copying commit number from GitHub repository

Now, back in your Git terminal type the following command:

resetting master

This will place this version of the commit at the HEAD of the list. Now to update the server:

Forcing master to update to specific commit

NOTE: Be VERY careful with this as it can erase all work done by others as it reverts to that specific point of the project. Everything that had been done after that point is lost.



Marc Frappier

Poultry Scientist by profession, Computer Scientist at heart. After many years in the poultry business, I have decided to give my passion for technology a shot.