8

Github GitHub - Bhupesh-V/ugit: 🚨️ ugit helps you undo your last git command wit...

 3 years ago
source link: https://github.com/Bhupesh-V/ugit
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Undo your last oopsie 🙈️ in git with ease

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

What's in the box

ugit 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 yellow_heart

  • 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)

Installation

ugit dependencies:

  • Bash>=3
  • GNU utils like awk, grep, tput etc
  • fzf
  1. Install the script using wget

    # Linux
    wget -q https://github.com/Bhupesh-V/ugit/releases/latest/download/ugit && chmod +x ugit && mv ugit $HOME/.local/bin/
    # Mac
    wget -q https://github.com/Bhupesh-V/ugit/releases/latest/download/ugit && chmod +x ugit && mv ugit /usr/local/bin

    or 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
  2. Verify installation

    ugit --version

    Optionally run ugit --help to see help and management commands

Please read warning

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.

Not satisfied? unamused

You can read my in-process guide on How to undo anything in Git

Author

bust_in_silhouetteBhupesh Varshney

Credit & Thanks

To all the SO threads that I will probably never visit again ;)

relaxed Show your support

Support me by giving a star if this project helped you! or just

memo License

Copyright © 2021 Bhupesh Varshney.
This project is MIT licensed.

wave Contributing

Please read the CONTRIBUTING file for the process of submitting pull requests to us.

Contributors sparkles

Thanks goes to these wonderful people (emoji key):

This project follows the all-contributors specification. Contributions of any kind welcome!


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK