More Video Demos โจ๏ธ
Undo git add
ugit.git.add.demo.mp4
Undo git branch -D
ugit.git.branch.delete.demo.mp4
Undo git merge
ugit.git.merge.demo.mp4
More Video Demos โจ๏ธ
Undo git add
ugit.git.add.demo.mp4
Undo git branch -D
ugit.git.branch.delete.demo.mp4
Undo git merge
ugit.git.merge.demo.mp4
- 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
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 to a previous version
- Undo
git merge
- Undo
git tag
(rename a tag) - Undo
git rebase
- Undo
git cherry-pick
- Undo
git worktree remove
(recover deleted work-tree)
Help me finish above tasks by contributing?
Have any other ideas/suggestions? Hop in to ugit discussions ๐ฌ๏ธ
ugit dependencies:
Bash
>=3- GNU utils like
awk
,grep
,tput
etc - fzf (Install latest version. Minimum required 0.21.0)
-
Install the script using
curl
Linux
curl -fsSL https://github.com/Bhupesh-V/ugit/releases/latest/download/ugit -o ugit && chmod +x ugit && mv ugit $HOME/.local/bin/
Mac
curl -fsSL https://github.com/Bhupesh-V/ugit/releases/latest/download/ugit -o ugit && chmod +x ugit && mv ugit /usr/local/bin
Or Arch Linux users can install ugit via AUR.
-
Verify installation
ugit --version
Optionally run
ugit --help
to see help and management commandsUndo your last oopsie in Git ๐ Usage: ugit [-h] [-v] [-u] ugit helps you undo your last git command without much effort Just run 'ugit' and search for what you want to undo Available options: -h, --help Print this help and exit -v, --version Print current ugit version -u, --update Update ugit Contact ๐ฌ: varshneybhupesh@gmail.com for assistance Read the guide: https://bhupesh.gitbook.io/notes/git/how-to-undo-anything-in-git
If you're using Zgenom:
- Add
zgenom load Bhupesh-V/ugit
to your.zshrc
along with your otherzgenom load
commands. zgenom reset && zgenom save
If you're using Antigen:
- Add
antigen bundle Bhupesh-V/ugit
to your.zshrc
where you've listed your other plugins. - Close and reopen your Terminal/iTerm window to refresh context and use the plugin. Alternatively, you can run
antigen bundle Bhupesh-V/ugit
in a running shell to haveantigen
load the new plugin.
If you're using oh-my-zsh:
-
Clone the repository into a new
ugit
directory in oh-my-zsh's plugin folder:git clone https://github.com/Bhupesh-V/ugit.git $ZSH_CUSTOM/plugins/ugit
-
Edit your
~/.zshrc
and addugit
โ same as clone directory โ to the list of plugins to enable:plugins=( ... ugit )
-
Then, restart your terminal application to refresh context and use the plugin. Alternatively, you can source your current shell configuration:
source ~/.zshrc
News
- Featured on Changelog News
- The guide was tweeted by GitHub (I was logging my research process there while building ugit)
Community
- Alexander Alemayhu made a youtube tutorial on Undoing Your Last Git Commit with Ugit
Git comes with a garbage collector (in case you didn't know) therefore undoing some commands will become impossible if the entries are deleted from the reflog. One way to prevent this is to increase default time limits before the reflog entries expire.
Add these configuration in your global .gitconfig
file:
[gc]
# default 90 days
reflogExpire = 200
Used to set how long records in a branches reflog should be preserved.
[gc]
# default 30 days
reflogExpireUnreachable = 90
Used to set how long inaccessible reflog records should be preserved.
You can read my in-process guide on How to undo anything in Git
๐ค Bhupesh Varshney
- Web : bhupesh-v.github.io
- Twitter : @bhupeshimself
- DEV : bhupesh
To all the SO threads that I will probably never visit again ;)
Support me by giving a โญ๏ธ if this project helped you! or just
Copyright ยฉ 2021 Bhupesh Varshney.
This project is MIT licensed.
Please read the CONTRIBUTING file for the process of submitting pull requests to us.
Thanks goes to these wonderful people (emoji key):
Sharan Aithal ๐ป ๐ |
Tabulate ๐ป ๐ฆ |
Joe Block ๐ป ๐ ๐ |
This project follows the all-contributors specification. Contributions of any kind welcome!