Skip to content

Instantly share code, notes, and snippets.

@luiarthur
Last active February 16, 2023 02:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luiarthur/c0c37506fefb55b6ea5cf42999fd68fa to your computer and use it in GitHub Desktop.
Save luiarthur/c0c37506fefb55b6ea5cf42999fd68fa to your computer and use it in GitHub Desktop.
Save everything in case of an emergency
#!/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