gunstage

🔫  `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

https://github.com/lucaslarson/gunstage

Science Score: 67.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • âś“
    CITATION.cff file
    Found CITATION.cff file
  • âś“
    codemeta.json file
    Found codemeta.json file
  • âś“
    .zenodo.json file
    Found .zenodo.json file
  • âś“
    DOI references
    Found 4 DOI reference(s) in README
  • âś“
    Academic publication links
    Links to: zenodo.org
  • â—‹
    Committers with academic emails
  • â—‹
    Institutional organization owner
  • â—‹
    JOSS paper metadata
  • â—‹
    Scientific vocabulary similarity
    Low similarity (11.2%) to scientific vocabulary

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

Keywords from Contributors

rdf documents sparql sequencers optimism argument-parser reaction symbolic genetic-algorithm robustness
Last synced: 6 months ago · JSON representation ·

Repository

🔫  `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

Basic Info
  • Host: GitHub
  • Owner: LucasLarson
  • License: other
  • Language: Shell
  • Default Branch: main
  • Homepage: https://git.io/gunstage
  • Size: 268 KB
Statistics
  • Stars: 64
  • Watchers: 1
  • Forks: 3
  • Open Issues: 2
  • Releases: 21
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
Created over 5 years ago · Last pushed 6 months ago
Metadata Files
Readme Changelog Funding License Code of conduct Citation Codeowners

readme.adoc

gunstage
--------

🔫 `git unstage` as a service

https://github.com/unixorn/awesome-zsh-plugins[image:https://github.com/sindresorhus/awesome/raw/a90737eb91368b3be912d1759f9573203ef9e70d/media/mentioned-badge.svg[đź•¶
Mentioned in Awesome,title="đź•¶ Mentioned in Awesome"]]
https://github.com/LucasLarson/gunstage/actions?query=workflow:Super-Linter[image:https://github.com/LucasLarson/gunstage/workflows/Super-Linter/badge.svg[GitHub
Super-Linter]]
https://github.com/LucasLarson/gunstage/blob/main/license.adoc[image:https://shields.io/badge/license-GPLP-blue[GPLP,title="GNU
General Public License for Pedants"]]
https://doi.org/10.5281/zenodo.6581323[image:https://zenodo.org/badge/DOI/10.5281/zenodo.6581323.svg[doi:10.5281/zenodo.6581323,title="Digital
Object Identifier"]]

What
~~~~
There are at least nine ways to unstage files in a Git repository.
Remembering which versions of Git support which syntax, under which
circumstances, reduced my productivity enough to publish this software
in response.

This is a command-line shell plugin for undoing `git add`. Too many
staged files? Can’t remember if it’s `git reset HEAD` or
`git restore --staged --`? Just remember `gunstage` or `git unstage`.

`gunstage` works exactly as you would expect it to as it performs the opposite
of `git add`. You can unstage directories and specific files in as few
commands as you’d like:
`gunstage file1.txt file2.txt directory/`.

Want to unstage everything? Well that’s as easy as
`gunstage --all` or `gunstage -A`.

Why
~~~
There is no `git unstage` command packaged as part of Git’s
default tooling. While `git restore --staged` often performs the task,
it’s not an obvious formula based on Git’s other commands.
`git restore --staged` is also unreliable, having
https://web.archive.org/web/20201214132901id_/github.blog/2019-08-16-highlights-from-git-2-23/#experimental-alternatives-for-git-checkout[entered
Git’s vocabulary in 2019^], after some 14 years of releases
without it. Many older releases remain in the wild and `git restore`
causes them to fail and choke. This software gracefully and silently accounts
for those situations by always sending the syntax that Git used from 2005 until
2019: `git reset`.

Instead of keeping up with the latest incarnation of Git, whose manual says
`git restore` “IS EXPERIMENTAL” and “THE BEHAVIOR MAY CHANGE” (emphasis
https://git-scm.com/docs/git-restore/2.30.0#_description[in original^]), you
can let this script do the remembering for you.

Minutiæ of the pedantic and querulous variety
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unstage content in a Git repository â€“ that is, to undo a
`git add` â€“ you must remember https://stackoverflow.com/q/58003030[which
commands^] are still in use out of the many I’m aware of having been
recommended so far:

1. `git restore --staged` (https://stackoverflow.com/a/16044987[source^]),
1. `git reset HEAD` (https://stackoverflow.com/a/6790291[source^]),
1. `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^]))
1. `git reset` (https://stackoverflow.com/a/6790285[source^]),
1. `git restore --staged --` (https://github.com/iain/dotfiles/commit/4c8f8cf7b849d723cbd0e029457dd24c42ea6263[source^]),
1. `git reset HEAD --` (https://stackoverflow.com/a/5798967[source^]),
1. `git rm --cached` (https://stackoverflow.com/a/5798967[source^]),
1. `git reset --` (https://stackoverflow.com/a/6919257[source^]), and even
1. `git rm --cached -- # ffs` (https://stackoverflow.com/a/30231316[source^]).

Next, you must be aware of repository context: if the repository is new
and no commit has occurred yet, then `git restore --staged` won’t work,
but `gunstage` will.

.Enter
[source,zsh]
----
gunstage # 🔫 git unstage as a service
git unstage # 🔫 it just works!
----
Its name is an abbreviation and portmanteau of `git unstage` arising by
analog from
https://github.com/ohmyzsh/ohmyzsh/blob/c99f3c50fa46a93be28be88632889404fff3b958/plugins/git/README.md#aliases[Oh My Zsh’s
other Git aliases^].

How
~~~
The scripts are written in Bourne shell-flavored, KornShell- and Zsh-compatible
Bash, which is masquerading as Z shell with a `.zsh` filename extension so
Oh My Zsh recognizes it as a plugin. What does that mean? The
syntax is
https://github.com/mcornella/dotfiles/blob/51feef648a2d68a82348ed4753ac3d6b65972510/zshenv#L10-L11[as
low-tech as possible^] while performing sophisticated work to do one thing and
do it well: `git unstage`.

Installation
^^^^^^^^^^^^
`gunstage` can be
https://gist.github.com/06009589d7887617e061481e22cf5a4a[installed as a
plugin^], https://fig.io/plugins/other/gunstage_LucasLarson[installed
using Fig^], or you can just clone this repository, run the following
command, and then restart your terminal:
[source,zsh]
----
$ printf '%s\n' '. /path/to/gunstage.plugin.zsh' \
  >>"${HOME%/}"'/.'"${SHELL##*[-./]}"'rc'
----

Requirements
~~~~~~~~~~~~
* https://github.com/zsh-users/zsh/tree/zsh-5.8[Zsh 5.8^] (or
  https://github.com/att/ast/tree/ksh93u[Ksh 93^] (or
  https://git.sv.gnu.org/cgit/bash.git/commit/?h=bash-5.0[Bash 5.0^])),
  and
* https://github.com/git/git/tree/v2.17.0[Git 2.17^].

Testing
~~~~~~~
I tested `gunstage` atop Zsh 5.8 and Bash 3.2 using Git:

* 2.17 on Ubuntu 18.04,
* 2.20 on Debian 9.12,
* 2.28, 2.29, and 2.30 on macOS 11.0 and Alpine 3.11 and 3.12,
  and

From macOS, I use https://github.com/gnachman/iTerm2[iTerm2^]; from iOS, I
use https://github.com/ish-app/ish[iSH^].

Credit
~~~~~~
This repository’s
https://web.archive.org/web/20220120220252/socialsharepreview.com/?url=https%3A%2F%2Fgithub.com%2FLucasLarson%2Fgunstage[preview
image^] was created by
https://github.com/twitter/twemoji/blob/7c1d3e9/2/svg/1f52b.svg[Twitter^]
in 2018.

Owner

  • Name: Lucas Larson
  • Login: LucasLarson
  • Kind: user
  • Location: New York

Citation (citation.cff)

---
cff-version: 1.2.0
message: "Cite this software by using this metadata."
title: gunstage
abstract: |
  `gunstage` or `git unstage` is a command-line tool for unstaging files in a
  Git repository without the need to memorize the many ways Git recommends it
  be done and when.
authors:
  - given-names: Lucas
    family-names: Larson
    orcid: https://orcid.org/0000-0002-0317-5426
version: 1.9.1
date-released: 2022-10-30
license: GPL-3.0-or-later
url: https://github.com/LucasLarson/gunstage
repository-code: https://github.com/LucasLarson/gunstage

GitHub Events

Total
  • Delete event: 5
  • Issue comment event: 2
  • Push event: 5
  • Pull request event: 5
  • Pull request review event: 1
  • Create event: 3
Last Year
  • Delete event: 5
  • Issue comment event: 2
  • Push event: 5
  • Pull request event: 5
  • Pull request review event: 1
  • Create event: 3

Committers

Last synced: 7 months ago

All Time
  • Total Commits: 300
  • Total Committers: 9
  • Avg Commits per committer: 33.333
  • Development Distribution Score (DDS): 0.397
Past Year
  • Commits: 4
  • Committers: 3
  • Avg Commits per committer: 1.333
  • Development Distribution Score (DDS): 0.5
Top Committers
Name Email Commits
Lucas Larson L****n@r****t 181
GitHub a****s@g****m 77
Renovate Bot b****t@r****m 24
dependabot[bot] 4****] 8
renovate[bot] 2****] 3
Restyled.io c****s@r****o 3
Joe Block j****b@u****t 2
deepsource-autofix[bot] 6****] 1
Rishi Kumar Ray 8****y 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 25
  • Total pull requests: 88
  • Average time to close issues: about 1 month
  • Average time to close pull requests: 13 days
  • Total issue authors: 3
  • Total pull request authors: 7
  • Average comments per issue: 0.36
  • Average comments per pull request: 0.24
  • Merged pull requests: 62
  • Bot issues: 2
  • Bot pull requests: 49
Past Year
  • Issues: 0
  • Pull requests: 3
  • Average time to close issues: N/A
  • Average time to close pull requests: 8 days
  • Issue authors: 0
  • Pull request authors: 2
  • Average comments per issue: 0
  • Average comments per pull request: 0.0
  • Merged pull requests: 2
  • Bot issues: 0
  • Bot pull requests: 1
Top Authors
Issue Authors
  • LucasLarson (22)
  • renovate[bot] (2)
  • unixorn (1)
Pull Request Authors
  • LucasLarson (37)
  • renovate[bot] (25)
  • dependabot[bot] (18)
  • deepsource-autofix[bot] (5)
  • restyled-io[bot] (2)
  • RishiKumarRay (2)
  • unixorn (1)
Top Labels
Issue Labels
enhancement (12) help wanted (7) good first issue (7) documentation (6) bug (5) security vulnerability (2) invalid (1) dependencies (1) github_actions (1) regression (1)
Pull Request Labels
dependencies (26) github_actions (24) enhancement (14) bug (6) documentation (5) invalid (2) security fix (1)

Packages

  • Total packages: 2
  • Total downloads: unknown
  • Total dependent packages: 0
    (may contain duplicates)
  • Total dependent repositories: 0
    (may contain duplicates)
  • Total versions: 42
proxy.golang.org: github.com/lucaslarson/gunstage
  • Versions: 21
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 7.0%
Average: 8.2%
Dependent repos count: 9.3%
Last synced: 6 months ago
proxy.golang.org: github.com/LucasLarson/gunstage
  • Versions: 21
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 7.0%
Average: 8.2%
Dependent repos count: 9.3%
Last synced: 6 months ago

Dependencies

.github/workflows/changelog.yml actions
  • actions/checkout v3 composite
  • ad-m/github-push-action v0.6.0 composite
  • ruby/setup-ruby v1 composite
.github/workflows/super-linter.yml actions
  • actions/checkout v3 composite
  • github/super-linter v4 composite