DEV Community

Devesh Saini
Devesh Saini

Posted on

Undo Git Commands

Hey folks,

I've found a neat way to add an undo feature to Git.

As you all know, Git itself relies on the .git folder, which contains all versioning information and metadata for your repository. Every Git command you run, from git add to git commit, modifies files within this .git folder. By using Mercurial (hg) to version control the .git folder itself, rgc (short for risky-git-command) allows you to save these changes and easily revert to this state if something goes wrong.

Here's how it adds in your workflow:

$ rgc do
$ <perform some risky git command>
Messed up?
$ rgc undo

Whether you're just starting with Git or have been using it for years, rgc can be a valuable tool to aid you in difficult situations.

This is a shell script (rgc) that's only 1KB in size. It's designed to be efficient and easy to use. For ubuntu users, I've built a .deb package, you can install using dpkg -i rgc.deb

Check the repo on Github: https://github.com/0xdsaini/rgc

Top comments (0)