{"id":28311485,"url":"https://github.com/amberpixels/git-undo","last_synced_at":"2025-08-02T21:08:33.626Z","repository":{"id":294817783,"uuid":"987723288","full_name":"amberpixels/git-undo","owner":"amberpixels","description":"Ctrl+Z for Git.","archived":false,"fork":false,"pushed_at":"2025-06-17T22:34:39.000Z","size":4912,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-17T23:29:43.715Z","etag":null,"topics":["git","git-plugin","golang","undo","zsh"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/amberpixels.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-05-21T13:45:21.000Z","updated_at":"2025-06-17T22:34:43.000Z","dependencies_parsed_at":null,"dependency_job_id":"0cd403db-5683-4177-be1a-532aa0d25237","html_url":"https://github.com/amberpixels/git-undo","commit_stats":null,"previous_names":["amberpixels/git-undo"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/amberpixels/git-undo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amberpixels%2Fgit-undo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amberpixels%2Fgit-undo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amberpixels%2Fgit-undo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amberpixels%2Fgit-undo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/amberpixels","download_url":"https://codeload.github.com/amberpixels/git-undo/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amberpixels%2Fgit-undo/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261186370,"owners_count":23121937,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["git","git-plugin","golang","undo","zsh"],"created_at":"2025-05-24T13:16:51.143Z","updated_at":"2025-08-02T21:08:33.611Z","avatar_url":"https://github.com/amberpixels.png","language":"Go","readme":"# *git undo* 🥐 — Ctrl+Z as Git plugin 💫\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"logo.png\" alt=\"Logo\" width=\"300\"/\u003e\u003cbr\u003e\n\u003c/p\u003e\n\n## 1. `git undo`: one simple command to undo (almost) any Git operation:\n\n```bash\ngit add .\ngit commit -m \"oops, wrong files\"\ngit undo                           # Back to before commit, files still staged\ngit undo                           # Back to before add, clean working directory\n```\n\n## 2. `git back`: undo navigation commands e.g. `git checkout/switch`:\n\n```bash\n# Assume we're on main\ngit switch feature-branch\ngit back # back to main\ngit back # back to feature-branch\n```\n\n## 3. `git undo undo` Undoed accidently? Undo it as well. (like Ctrl+Shift+Z)\n\n```bash\ngit add .\ngit commit -m \"oops, wrong files\"\ngit undo                           # Back to before commit, files still staged\ngit undo undo                      # Back to commited again\n```\n\n## 4. `git undo --dry-run`: see what would be undone:\n\n```bash\n# Make some changes\ngit add file.txt\ngit undo --dry-run # shows hint to run \"git restore --staged .\"\ngit commit -m \"test commit\"\ngit undo --dry-run # shows hint to run \"git reset --soft HEAD~1\"\n```\n\n## 5. Debug options: `git undo --verbose`, `git undo --log`\n\nNow you can use Git confidently, knowing any command is easily undoable.\n\n## Installation Options\n\n### One-liner (Recommended)\n```bash\ncurl -fsSL https://raw.githubusercontent.com/amberpixels/git-undo/main/install.sh | bash\n```\n### Manual Installation (useful for development, debugging, troubleshooting)\n```bash\ngit clone https://github.com/amberpixels/git-undo.git\ncd git-undo\n./install.sh\n```\n\n**Requirements:** Git, Go ≥ 1.21, Bash/Zsh\n\n## Suggestions for aliases\n\n```bash\nalias gu=\"git undo\"\nalias gub=\"git back\"\nalias guu=\"git undo undo\"\nalias gul=\"git undo --log | head\"\n```\n\n## Supported commands to be undo-ed:\n\n| Git Command | How it's undone | Notes |\n|-------------|-----------------|-------|\n| **`git add`** | `git restore --staged \u003cfiles\u003e` or `git reset \u003cfiles\u003e` | Unstages files. Uses `git reset` if no HEAD exists |\n| **`git commit`** | `git reset --soft HEAD~1` | Keeps changes staged. Handles merge commits and tagged commits |\n| **`git branch \u003cname\u003e`** | `git branch -D \u003cname\u003e` | Deletes the created branch |\n| **`git checkout -b \u003cname\u003e`** | `git branch -D \u003cname\u003e` | Deletes branch created by checkout -b |\n| **`git switch -c \u003cname\u003e`** | `git branch -D \u003cname\u003e` | Deletes branch created by switch -c |\n| **`git switch \u003cbranch\u003e`** | `git switch -` | Returns to previous branch |\n| **`git merge \u003cbranch\u003e`** | `git reset --merge ORIG_HEAD` | Handles both fast-forward and merge commits |\n| **`git cherry-pick \u003ccommit\u003e`** | `git reset --hard HEAD~1` | Removes cherry-picked commit |\n| **`git revert \u003ccommit\u003e`** | `git reset --hard HEAD~1` | Removes revert commit |\n| **`git reset`** | `git reset \u003cprevious-head\u003e` | Restores to previous HEAD position using reflog |\n| **`git stash` / `git stash push`** | `git stash pop` | Pops and removes the stash |\n| **`git rm \u003cfiles\u003e`** | `git restore --source=HEAD --staged --worktree \u003cfiles\u003e` | Restores removed files |\n| **`git rm --cached \u003cfiles\u003e`** | `git add \u003cfiles\u003e` | Re-adds files to index |\n| **`git mv \u003cold\u003e \u003cnew\u003e`** | `git mv \u003cnew\u003e \u003cold\u003e` | Reverses the move operation |\n| **`git tag \u003cname\u003e`** | `git tag -d \u003cname\u003e` | Deletes the created tag |\n| **`git restore --staged \u003cfiles\u003e`** | `git add \u003cfiles\u003e` | Re-stages the files |\n\n### Not Yet Supported (Returns helpful error message):\n\n| Git Command | Reason |\n|-------------|--------|\n| **`git checkout \u003cbranch\u003e`** | Only `checkout -b` is supported (regular checkout navigation not undoable) |\n| **`git clean`** | Cannot recover deleted untracked files (would need pre-operation backup) |\n| **`git restore --worktree`** | Previous working tree state unknown |\n| **`git restore --source=\u003cref\u003e`** | Previous state from specific reference unknown |\n| **`git stash pop/apply`** | Would need to re-stash, which is complex |\n| **Branch/tag deletion** | Cannot restore deleted branches/tags (would need backup) |\n\n## How It Works\n\nAfter installation both `shell hooks` and `git hooks` are installed, that track any git command and send them to `git-undo` (a git plugin) binary. There git commands are categorized and stored in a tiny log file (`.git/git-undo/commands`). Later, when calling `git undo` it reads the log and decide if it's possible (and how) to undo previous command.\n\n## Examples\n\n**Undo a merge:**\n```bash\ngit merge feature-branch\ngit undo                 # resets --merge ORIG_HEAD\n```\n\n**Undo adding specific files:**\n```bash\ngit add file1.js file2.js\ngit undo                 # unstages just those files\n```\n\n**Undo branch creation:**\n```bash\ngit checkout -b new-feature\ngit undo                 # deletes branch, returns to previous\n```\n\n### Self-Management\n\nGet the version information:\n```bash\ngit undo self version # same as git undo version\n```\n\nUpdate to latest version:\n```bash\ngit undo self update\n```\n\nUninstall:\n```bash\ngit undo self uninstall\n```\n\n## Contributing\n\nFound a Git command that should be undoable? [Open an issue](https://github.com/amberpixels/git-undo/issues) or submit a PR!\n\n## License\n\nMIT - see [LICENSE](LICENSE) file.\n\n---\n\n**Make Git worry-free!**\n[⭐ Star this repo](https://github.com/amberpixels/git-undo) if `git undo` makes your development workflow better!\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famberpixels%2Fgit-undo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famberpixels%2Fgit-undo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famberpixels%2Fgit-undo/lists"}