DEV Community

Cover image for Undo your last git mistake with ugit
Bhupesh Varshney ๐Ÿ‘พ
Bhupesh Varshney ๐Ÿ‘พ

Posted on • Originally published at on

Undo your last git mistake with ugit

So I have been working on this little tool called ugit (and was finally able to release a stable version), the goal is to make it easier for beginner to intermediate git users to undo their last (accidental) git command. Because we are not perfect and commit mistakes.

โ€œOh wait I deleted the auth-jwt branch without merging!! fuckโ€

Opens browser

โ€œHow to restore deleted branchโ€

Wastes 5 minutes reading the thread,

Brain context switch, losses focus

โ€œAarrgh, Git sucksโ€

Failure is a good way to learn something new but how many times are you going to mess up with git, if your ultimate goal is to deliver the new feature in your startup as fast as possible, huh? Git is great but itโ€™s not really good with developer experience (DX).

Yo bhupesh, I can just you know alias this command. Oh cool, good luck remembering that alias after 1 month when you fuck-up again.

If you are in the gang of getting things done, adding ugit might be a good choice for you.

GitHub logo Bhupesh-V / ugit

๐Ÿšจ๏ธ ugit helps undo git commands. Your damage control git buddy. Undo from 19+ git scenarios.


ugit logo

Undo your last oopsie ๐Ÿ™ˆ๏ธ in git

build ugit License: MIT GitHub all releases platform support linux and macos Twitter: bhupeshimself

ugit demo: restore file gif

More Video Demos โœจ๏ธ

Undo git add


Undo git branch -D


Undo git merge


Why ugit

  • You did an accidental git command you didn't want to.
  • You don't want to waste your time searching on how to undo ...
  • Because ugit is cool

Motivations behind writing ugit ๐Ÿ™‡โ€โ™‚๏ธ๏ธ

What's in the box

ugit/git-undo supports undoing following operations, some are a WIP. If you know of any other operations that can be undone and is not in the list, make sure to send a quick PR ๐Ÿ’›๏ธ

  • Undo git commit
  • Undo git add
  • Undo git push
  • Undo git branch -D (branch delete)
  • Undo git pull
  • Undo git reset
  • Undo git tag -d (tag delete)
  • Undo git stash apply
  • Undo git stash pop/drop/clear
  • Undo accidental file delete (Restore a deleted file after a commit)
  • Undo (Restore) a fileโ€ฆ

Ok enough talking.

What is ugit?

Itโ€™s just a simple shell script with guided programmatic steps to undo your last git command, powered by FZF built for people who live and work with terminals every day.

Guided Tutorials

Below are some GIF demos of undoing some git operations, the list is long (around 17 scenarios) but I am only demonstrating some common ones.

Undoing git add

Undoing git branch -D (Restore deleted branch)

Undoing/Restoring file to previous version

Undoing git merge

I donโ€™t like your stupid script

sad dogo crying

Cool, I mean we are still friends right?? Friends help friends avoid git mistakes, thatโ€™s why I wrote an accompanying text guide on How to undo anything in Git.

Share it with your friends, co-workers. No hard feelings

Peace โœŒ๏ธ

Discussion (4)

moopet profile image
Ben Sinclair • Edited on

Yo bhupesh, I can just you know alias this command.

That was literally gong through my head for the first half of this post.

Now, I actually want to install this. It's a really smart idea.

bhupesh profile image
Bhupesh Varshney ๐Ÿ‘พ Author

I like aliasing commands too
Sometimes commands become complex, half of the time I don't have good enough 3-4 letters aliases (since they are all booked)

I hope ugit helps, contributions/feedback are always welcomed <3

deven96 profile image
Diretnan Domnan

Really like this

bhupesh profile image
Bhupesh Varshney ๐Ÿ‘พ Author

Thanks :)
Do provide some feedback though, when you try it
Hop into