{"id":14069575,"url":"https://github.com/LucasLarson/gunstage","last_synced_at":"2025-07-30T05:32:34.810Z","repository":{"id":38381375,"uuid":"293950625","full_name":"LucasLarson/gunstage","owner":"LucasLarson","description":"🔫  `git unstage` as a service: a Git plugin for the shell that automagically remembers all the different commands there are to remove files from staging and when to use each","archived":false,"fork":false,"pushed_at":"2025-04-26T08:09:48.000Z","size":273,"stargazers_count":64,"open_issues_count":2,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-12T03:51:07.352Z","etag":null,"topics":["git-add","git-addons","git-plugin","git-undo","git-unstage","gunstage","hacktoberfest","lucaslarson","oh-my-zsh-plugin","ohmyzsh-plugin","omz-plugin","posix-compliant","zsh-plugin","zsh-plugins"],"latest_commit_sha":null,"homepage":"https://git.io/gunstage","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LucasLarson.png","metadata":{"files":{"readme":"readme.adoc","changelog":"changelog.md","contributing":null,"funding":".github/funding.yml","license":"license.adoc","code_of_conduct":".github/code_of_conduct.md","threat_model":null,"audit":null,"citation":"citation.cff","codeowners":".github/codeowners","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"LucasLarson"}},"created_at":"2020-09-08T23:28:23.000Z","updated_at":"2025-04-26T08:09:51.000Z","dependencies_parsed_at":"2024-01-03T04:17:22.358Z","dependency_job_id":"175d2840-b620-446b-b853-f9ec0e759693","html_url":"https://github.com/LucasLarson/gunstage","commit_stats":null,"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"purl":"pkg:github/LucasLarson/gunstage","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LucasLarson%2Fgunstage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LucasLarson%2Fgunstage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LucasLarson%2Fgunstage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LucasLarson%2Fgunstage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LucasLarson","download_url":"https://codeload.github.com/LucasLarson/gunstage/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LucasLarson%2Fgunstage/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267815187,"owners_count":24148356,"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","status":"online","status_checked_at":"2025-07-30T02:00:09.044Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-add","git-addons","git-plugin","git-undo","git-unstage","gunstage","hacktoberfest","lucaslarson","oh-my-zsh-plugin","ohmyzsh-plugin","omz-plugin","posix-compliant","zsh-plugin","zsh-plugins"],"created_at":"2024-08-13T07:07:03.580Z","updated_at":"2025-07-30T05:32:32.126Z","avatar_url":"https://github.com/LucasLarson.png","language":"Shell","readme":"gunstage\n--------\n\n🔫 `git unstage` as a service\n\nhttps://github.com/unixorn/awesome-zsh-plugins[image:https://github.com/sindresorhus/awesome/raw/a90737eb91368b3be912d1759f9573203ef9e70d/media/mentioned-badge.svg[🕶\nMentioned in Awesome,title=\"🕶 Mentioned in Awesome\"]]\nhttps://github.com/LucasLarson/gunstage/actions?query=workflow:Super-Linter[image:https://github.com/LucasLarson/gunstage/workflows/Super-Linter/badge.svg[GitHub\nSuper-Linter]]\nhttps://github.com/LucasLarson/gunstage/blob/main/license.adoc[image:https://shields.io/badge/license-GPLP-blue[GPLP,title=\"GNU\nGeneral Public License for Pedants\"]]\nhttps://doi.org/10.5281/zenodo.6581323[image:https://zenodo.org/badge/DOI/10.5281/zenodo.6581323.svg[doi:10.5281/zenodo.6581323,title=\"Digital\nObject Identifier\"]]\n\nWhat\n~~~~\nThere are at least nine ways to unstage files in a Git\u0026nbsp;repository.\nRemembering which versions of Git support which syntax, under which\ncircumstances, reduced my productivity enough to publish this software\nin\u0026nbsp;response.\n\nThis is a command-line shell plugin for undoing `git add`. Too many\nstaged\u0026nbsp;files? Can’t remember if it’s `git reset HEAD` or\n`git restore --staged --`? Just remember `gunstage` or `git unstage`.\n\n`gunstage` works exactly as you would expect it to as it performs the opposite\nof `git add`. You can unstage directories and specific files in as few\ncommands as you’d\u0026nbsp;like:\n`gunstage file1.txt file2.txt directory/`.\n\nWant to unstage everything? Well that’s as easy as\n`gunstage --all` or `gunstage -A`.\n\nWhy\n~~~\nThere is no `git unstage` command packaged as part of Git’s\ndefault\u0026nbsp;tooling. While `git restore --staged` often performs the task,\nit’s not an obvious formula based on Git’s other\u0026nbsp;commands.\n`git restore --staged` is also\u0026nbsp;unreliable, having\nhttps://web.archive.org/web/20201214132901id_/github.blog/2019-08-16-highlights-from-git-2-23/#experimental-alternatives-for-git-checkout[entered\nGit’s vocabulary in\u0026nbsp;2019^], after some\u0026nbsp;14 years of releases\nwithout\u0026nbsp;it. Many older releases remain in the wild and `git restore`\ncauses them to fail and choke. This software gracefully and silently accounts\nfor those situations by always sending the syntax that Git used from 2005 until\n2019: `git reset`.\n\nInstead of keeping up with the latest incarnation of Git, whose manual says\n`git restore` “IS EXPERIMENTAL” and “THE BEHAVIOR MAY CHANGE” (emphasis\nhttps://git-scm.com/docs/git-restore/2.30.0#_description[in original^]), you\ncan let this script do the remembering for\u0026nbsp;you.\n\nMinutiæ of the pedantic and querulous variety\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\nTo unstage content in a Git repository\u0026nbsp;– that is, to undo a\n`git add`\u0026nbsp;– you must remember https://stackoverflow.com/q/58003030[which\ncommands^] are still in use out of the many I’m aware of having been\nrecommended so\u0026nbsp;far:\n\n1. `git restore --staged` (https://stackoverflow.com/a/16044987[source^]),\n1. `git reset HEAD` (https://stackoverflow.com/a/6790291[source^]),\n1. `git reset -q HEAD --` (https://github.com/gggritso/gggritso.com/blob/a07b620/_posts/2015-08-23-human-git-aliases.md#L45[source^] (https://news.ycombinator.com/item?id=17987033#17987696[via^]))\n1. `git reset` (https://stackoverflow.com/a/6790285[source^]),\n1. `git restore --staged --` (https://github.com/iain/dotfiles/commit/4c8f8cf7b849d723cbd0e029457dd24c42ea6263[source^]),\n1. `git reset HEAD --` (https://stackoverflow.com/a/5798967[source^]),\n1. `git rm --cached` (https://stackoverflow.com/a/5798967[source^]),\n1. `git reset --` (https://stackoverflow.com/a/6919257[source^]), and\u0026nbsp;even\n1. `git rm --cached -- # ffs` (https://stackoverflow.com/a/30231316[source^]).\n\nNext, you must be aware of repository\u0026nbsp;context: if the repository is new\nand no commit has occurred yet, then `git restore --staged` won’t\u0026nbsp;work,\nbut `gunstage`\u0026nbsp;will.\n\n.Enter\n[source,zsh]\n----\ngunstage # 🔫 git unstage as a service\ngit unstage # 🔫 it just works!\n----\nIts name is an abbreviation and portmanteau of `git unstage` arising by\nanalog from\nhttps://github.com/ohmyzsh/ohmyzsh/blob/c99f3c50fa46a93be28be88632889404fff3b958/plugins/git/README.md#aliases[Oh\u0026nbsp;My\u0026nbsp;Zsh’s\nother Git\u0026nbsp;aliases^].\n\nHow\n~~~\nThe scripts are written in Bourne shell-flavored, KornShell- and Zsh-compatible\nBash, which is masquerading as Z\u0026nbsp;shell with a `.zsh` filename extension so\nOh\u0026nbsp;My\u0026nbsp;Zsh recognizes it as a plugin. What does that mean? The\nsyntax is\nhttps://github.com/mcornella/dotfiles/blob/51feef648a2d68a82348ed4753ac3d6b65972510/zshenv#L10-L11[as\nlow-tech as possible^] while performing sophisticated work to do one thing and\ndo it well: `git unstage`.\n\nInstallation\n^^^^^^^^^^^^\n`gunstage` can be\nhttps://gist.github.com/06009589d7887617e061481e22cf5a4a[installed as a\nplugin^], https://fig.io/plugins/other/gunstage_LucasLarson[installed\nusing Fig^], or you can just clone this repository, run the following\ncommand, and then restart your terminal:\n[source,zsh]\n----\n$ printf '%s\\n' '. /path/to/gunstage.plugin.zsh' \\\n  \u003e\u003e\"${HOME%/}\"'/.'\"${SHELL##*[-./]}\"'rc'\n----\n\nRequirements\n~~~~~~~~~~~~\n* https://github.com/zsh-users/zsh/tree/zsh-5.8[Zsh\u0026nbsp;5.8^] (or\n  https://github.com/att/ast/tree/ksh93u[Ksh\u0026nbsp;93^] (or\n  https://git.sv.gnu.org/cgit/bash.git/commit/?h=bash-5.0[Bash\u0026nbsp;5.0^])),\n  and\n* https://github.com/git/git/tree/v2.17.0[Git\u0026nbsp;2.17^].\n\nTesting\n~~~~~~~\nI tested `gunstage` atop Zsh\u0026nbsp;5.8 and Bash\u0026nbsp;3.2 using\u0026nbsp;Git:\n\n* 2.17 on Ubuntu\u0026nbsp;18.04,\n* 2.20 on Debian\u0026nbsp;9.12,\n* 2.28, 2.29, and 2.30 on macOS\u0026nbsp;11.0 and Alpine\u0026nbsp;3.11 and\u0026nbsp;3.12,\n  and\n\nFrom macOS, I use https://github.com/gnachman/iTerm2[iTerm2^]; from iOS, I\nuse\u0026nbsp;https://github.com/ish-app/ish[iSH^].\n\nCredit\n~~~~~~\nThis repository’s\nhttps://web.archive.org/web/20220120220252/socialsharepreview.com/?url=https%3A%2F%2Fgithub.com%2FLucasLarson%2Fgunstage[preview\nimage^] was created by\nhttps://github.com/twitter/twemoji/blob/7c1d3e9/2/svg/1f52b.svg[Twitter^]\nin\u0026nbsp;2018.\n","funding_links":["https://github.com/sponsors/LucasLarson"],"categories":["Plugins","Shell"],"sub_categories":["ZSH on Windows"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLucasLarson%2Fgunstage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FLucasLarson%2Fgunstage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLucasLarson%2Fgunstage/lists"}