If you have screwed something up in the codebase, you might need to revert to the previous (or any other) commit. This is quite simple and the only thing you need is the commit id. You can find it by clicking on the history of commits button as shown below.

screenshot

Now, click on the copy button next to the chosen commit id.

screenshot

Git

Once you have the commit id, go to your codebase using the terminal and type the following. This will switch to a branch with the specified commit id.

git checkout <commit_id> .

Now, you are back to the previous version of your codebase, but only locally. Let’s push the code back to github.

git add .
git commit -m 'reverting back to <commit_id>'
git push

For any questions please use the contact form here.

Leave a Reply

Your email address will not be published.