Last active
February 16, 2023 02:53
-
-
Save luiarthur/c0c37506fefb55b6ea5cf42999fd68fa to your computer and use it in GitHub Desktop.
Save everything in case of an emergency
This file contains 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
#!/bin/bash | |
# Usage: | |
# In case of emergency, IF POSSIBLE, run | |
# > git fire | |
# | |
# Unsaved changes will be saved and pushed to a new branch named: | |
# $USER/fire/some-long-hash | |
# | |
# Optionally, a name can be provided, e.g. | |
# > git fire some-short-name | |
# | |
# Then, unsaved changes will be at: | |
# $USER/fire/some-short-name | |
# | |
# Installation: | |
# 1. Put this script in: $HOME/bin/git-fire | |
# 2. Execute: `chmod +x $HOME/bin/git-fire` | |
# 3. Be sure to add $HOME/bin to $PATH | |
# Name of my temporary branch. | |
uid=`uuidgen` | |
[[ "$#" -ne 1 ]] || uid=$1 | |
branch_name="$USER/fire/$uid" | |
git stash | |
git checkout -b $branch_name | |
git stash pop | |
git add -A | |
git commit -m "Fire! Commit everything." | |
git push --set-upstream origin $branch_name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment