/github-for-non-tech

How to rollback changes in GitHub?

Learn how to rollback changes in GitHub step-by-step—from checking status and discarding unstaged changes to reverting commits and force pushing updates.

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 rollback changes in GitHub?

 
Step 1: Check Your Current Git Status
 

  • Open your terminal or command prompt in your project directory.
  • Run git status to see which files are modified, staged, or untracked.
  • This helps you decide what kind of rollback you need.

git status

 
Step 2: Discard Unstaged Local Changes
 

  • If you have modified files that you haven’t staged yet and want to discard those changes, use git checkout (Git 2.23+ uses git restore).

// For older Git versions
git checkout -- path/to/file

// Or with Git 2.23+
git restore path/to/file

 
Step 3: Unstage Staged Changes
 

  • When you’ve added files to the staging area (git add) but want to remove them from staging without deleting your edits, use git reset.

git reset HEAD path/to/file

 
Step 4: Revert a Commit Without Changing History
 

  • Use git revert if the commit is already pushed or merged and you want to create a new commit that undoes the changes.
  • This approach is safe for shared repositories.

git revert <commit-hash>
# Follow prompts to edit commit message, then save and exit.

 
Step 5: Reset to a Previous Commit (Local History Rewrite)
 

  • To move your current branch pointer to an earlier commit and discard all changes after it, use git reset --hard.
  • Be careful: this permanently deletes uncommitted work and any commits after the target.

git reset --hard <commit-hash>

 
Step 6: Force Push to Remote (If You Rewrote Public History)
 

  • If you used git reset --hard on a branch that others pull from, you must force-push to overwrite the remote history.
  • Use with caution to avoid disrupting collaborators.

git push --force origin branch-name

 
Step 7: Revert a Merged Pull Request via GitHub UI
 

  • Navigate to the merged pull request in your repository on GitHub.
  • Click the Revert button. GitHub will create a new pull request that undoes the changes of the original.
  • Review, merge the new PR, and the original merge is effectively rolled back.

 
Step 8: Verify Your Rollback
 

  • Run git log or view the commit history on GitHub to confirm the rollback or revert commits are present.
  • Run git status again to ensure your working directory is clean.

git log --oneline
git status

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