Skip to content

Instantly share code, notes, and snippets.

View brookinc's full-sized avatar

Brook McEachern brookinc

View GitHub Profile
@brookinc
brookinc / stashstaged.sh
Last active November 23, 2021 09:34
A script to `git stash` only the currently staged changes.
#!/usr/bin/env bash
# This script stashes the currently staged changes, and leaves everything else in the working directory as-is.
# (source: https://stackoverflow.com/questions/14759748/stashing-only-staged-changes-in-git-is-it-possible/39644782#39644782)
# Prompt for the desired repo path
REPOPATH=
read -p "Enter the repo path, or press ENTER for current dir: " REPOPATH
# Read the desired stash description from the command line, or prompt the user for it if necessary