Category: Git sync
Resource links
Updated

This solution is summarized from an archived support forum post. This information may have changed. If you notice an error, please let us know in Discord.

How Do I Revert to a Previous Commit of My App?

Issue

As a git novice, I need to revert my app to a previous version from 2 commits ago. I am unsure how to do this and also want to know if it is possible to delete the "bad" commits or create a new branch from the "good" commit. I need some guidance to accomplish this.

Resolution

To revert your Git repository to a previous commit, you can use the git revert or git reset commands. Here’s how you can do it:

Option 1: Revert the commits

  1. Open up your terminal and navigate to the directory where your app is located. Use git log to view the commit history and find the commit hash of the “good” commit.
  2. Use git revert <commit hash> to revert the commits. This will create a new commit that is the opposite of the reverted commits.
  3. Push the changes to the remote repository.

Option 2: Reset to the previous commit and create a new branch

  1. Open up your terminal and navigate to the directory where your app is located. Use git log to view the commit history and find the commit hash of the “good” commit.
  2. Use git reset --hard <commit hash> to reset the repository to the previous commit. This will discard any changes made after the “good” commit.
  3. Use git checkout -b <new branch name> to create a new branch with the reset state.
  4. Push the new branch to the remote repository.

Note that these operations will permanently remove the commits you’ve deleted from the branch. If you want to keep a record of the deleted commits, you can create a new branch containing those commits before performing the deletion.

 

Option 3: Revert the changes using the GUI

For an easy GUI way of doing this, you can clone the Appsmith repository into GitHub Desktop and revert the changes as shown in the GitHub docs.