Git Recover is a simple CLI tool written in Go that helps you recover accidentally deleted git branches. It scans for dangling commits and reflog entries to find lost work, presents them in an interactive TUI, and allows you to restore them to a new branch.>
go install github.com/ibrahimraimi/git-recover@latestOr build from source:
git clone https://github.com/ibrahimraimi/git-recover.git
cd git-recover
go build -o git-recover- Recover Lost Commits: Finds dangling commits and reflog entries.
- Interactive TUI: Browse commits with a user-friendly interface.
- Commit Preview: View commit details and diffs in a split-pane view before recovering.
- Cross-Platform: Works on Linux, macOS, and Windows.
Navigate to your git repository and run the tool:
git-recover- Up / k: Move cursor up
- Down / j: Move cursor down
- Enter: Select commit to recover
- Esc: Cancel selection / Quit
- q / Ctrl+c: Quit
When you select a commit, you will be prompted to enter a name for the new branch. Press Enter to confirm and create the branch.
The tool uses git fsck --lost-found to find dangling commits and git reflog to find recent HEAD movements. It aggregates these commits and displays them in a list. When you choose to recover a commit, it simply runs git branch <new-branch-name> <commit-hash>.
Contributions are welcome! Please read CONTRIBUTING.md for details on how to submit pull requests and report issues.
MIT