Last active
March 24, 2022 07:45
-
-
Save xphere/cb03e51a456112afe94c3f7cbe1bd9e0 to your computer and use it in GitHub Desktop.
Allows to store/recover state of current git branch. Like stash but keeping index and branch tracking.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[alias] | |
index-is-clean = !git diff-index --cached --quiet HEAD | |
recover = !f() { local REV=$(git rev); [ "$(git commit-message)" = ::modified ] && git reset -q HEAD~; [ "$(git commit-message)" = ::indexed ] && git reset -q --soft HEAD~; [ $(git rev) = $REV ] || echo 'Current state recovered'; }; f | |
rev = rev-parse HEAD | |
store = !f() { local REV="$(git rev)"; git index-is-clean || git unsafe-commit '::indexed'; git working-is-clean || $(git add -A && git unsafe-commit '::modified'); [ "$(git rev)" = "$REV" ] || echo 'Current state stored'; }; f | |
unsafe-commit = !git commit --no-verify -q -m | |
working-is-clean = !git diff-files --quiet && [ -z "$(git ls-files --exclude-standard --others)" ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment