/github-for-non-tech

How to revert to a previous version of the project?

Learn how to safely revert to a previous project version with Git. This guide covers commit checkout, branch creation, hard resets, and using git revert.

Matt Graham, CEO of Rapid Developers

Book a call with an Expert

Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.

Book a free No-Code consultation

How to revert to a previous version of the project?

 
Step 1: Open Your Terminal or Command Prompt
 

Open the terminal (Linux/macOS) or Git Bash/Command Prompt (Windows) so you can run Git commands.

 
Step 2: Navigate to Your Local Repository
 

Use the cd command to move into the folder where your project is stored.


cd path/to/your/project

 
Step 3: View the Commit History
 

Run git log in a concise form to find the commit hash you want to revert to.

  • The hash is the series of characters at the start of each line.
  • You’ll use that hash in the next step.

git log --oneline

 
Step 4: Check Out the Desired Commit Locally
 

This lets you inspect the project at that point in time without altering your current branch permanently.


git checkout COMMIT\_HASH

Replace COMMIT_HASH with the actual identifier (for example, a1b2c3d).

 
Step 5: Create a New Branch from the Old Commit (Optional but Safe)
 

If you want to preserve your current work, create a new branch at that commit first.

  • This branch will hold the reverted state.

git checkout -b revert-to-old-version

 
Step 6: Hard Reset Your Main Branch to That Commit
 

If you prefer to move your existing branch (for example, main) back in time, switch back to it and reset it.

  • WARNING: A hard reset rewrites commit history and can discard uncommitted changes.

git checkout main
git reset --hard COMMIT\_HASH

 
Step 7: Push the Reverted State to GitHub
 

After resetting, update the remote branch. If you reset the main branch, you must force-push.


git push origin main --force
  • Force-pushing rewrites history on GitHub. Coordinate with your team first.

 
Step 8: Alternative Method—Use git revert to Create a New “Undo” Commit
 

Instead of rewriting history, you can generate a new commit that reverses one or more earlier commits. This is safer for shared branches.


git checkout main
git revert COMMIT\_HASH
git push origin main
  • This will prompt you to confirm the commit message; save and close to complete.
  • Multiple commits can be reverted in a single command by listing hashes.

 
Step 9: Verify the Reverted Version on GitHub
 

Go to your repository on GitHub and confirm that the files and commit history reflect the previous version you intended.

Want to explore opportunities to work with us?

Connect with our team to unlock the full potential of no-code solutions with a no-commitment consultation!

Book a Free Consultation

Client trust and success are our top priorities

When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.

Rapid Dev was an exceptional project management organization and the best development collaborators I've had the pleasure of working with. They do complex work on extremely fast timelines and effectively manage the testing and pre-launch process to deliver the best possible product. I'm extremely impressed with their execution ability.

CPO, Praction - Arkady Sokolov

May 2, 2023

Working with Matt was comparable to having another co-founder on the team, but without the commitment or cost. He has a strategic mindset and willing to change the scope of the project in real time based on the needs of the client. A true strategic thought partner!

Co-Founder, Arc - Donald Muir

Dec 27, 2022

Rapid Dev are 10/10, excellent communicators - the best I've ever encountered in the tech dev space. They always go the extra mile, they genuinely care, they respond quickly, they're flexible, adaptable and their enthusiasm is amazing.

Co-CEO, Grantify - Mat Westergreen-Thorne

Oct 15, 2022

Rapid Dev is an excellent developer for no-code and low-code solutions.
We’ve had great success since launching the platform in November 2023. In a few months, we’ve gained over 1,000 new active users. We’ve also secured several dozen bookings on the platform and seen about 70% new user month-over-month growth since the launch.

Co-Founder, Church Real Estate Marketplace - Emmanuel Brown

May 1, 2024 

Matt’s dedication to executing our vision and his commitment to the project deadline were impressive. 
This was such a specific project, and Matt really delivered. We worked with a really fast turnaround, and he always delivered. The site was a perfect prop for us!

Production Manager, Media Production Company - Samantha Fekete

Sep 23, 2022