├── LICENSE ├── README.md ├── git-fire └── package.json /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 - 2019 Nimit Kalra 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # `git-fire` :fire: 2 | 3 | ### ![Inspiration](https://i.imgur.com/3POtveC.jpg) 4 | 5 | `git-fire` is a Git plugin that **helps in the event of an emergency** by switching to the repository's root directory, adding all current files, committing, and pushing commits and all stashes to a new branch (to prevent merge conflicts). 6 | 7 | **Alias it to [`git out`](https://np.reddit.com/r/ProgrammerHumor/comments/3nc531/in_case_of_fire/cvmxnv1) or [`git going`](https://np.reddit.com/r/ProgrammerHumor/comments/3nc531/in_case_of_fire/cvmsajb) for comedic effect.** 8 | 9 | - `git config --global alias.out fire` 10 | - `git config --global alias.going fire` 11 | 12 | ## What It Does 13 | 14 | - changes directory to root directory of the repository 15 | - creates new branch `fire---` 16 | - adds all files 17 | - commits with `"Fire! Branch "` or custom message 18 | - pushes commits to remote 19 | - pushes all stashes to remote 20 | 21 | ## Usage 22 | 23 | `git-fire ` 24 | 25 | `` is optional. If not specified, `"Fire! Branch fire---"` will be used. 26 | 27 | ## Installation 28 | 29 | Just copy `git-fire` to your `$PATH` and ensure it is an executable (`chmod +x git-fire`) and you're good to go. 👍 30 | 31 | `git-fire` is also available via [`npm`](https://npmjs.com/git-fire). Just run `npm install -g git-fire`, which will copy the `git-fire` binary to your `$PATH`. 32 | 33 | Also make sure you have Git installed. 34 | 35 | ## Disclaimer 36 | 37 | Your life is always more valuable than any code. You should leave the building immediately in a true emergency. 38 | 39 | Code can be re-written, but humans cannot. 40 | 41 | ## Credit 42 | 43 | Originally seen on [Hackathon Hackers Facebook](https://www.facebook.com/groups/hackathonhackers) group. 44 | 45 | [Original Reddit post](https://www.reddit.com/r/ProgrammerHumor/comments/3nc531/in_case_of_fire/) 46 | 47 | [Image source](https://instagram.com/p/8N8J8wRgPq/) | [Printable Image](http://imgur.com/IiAdxbB) | Artist: [Ákos Szokodi](https://github.com/szokodiakos) 48 | -------------------------------------------------------------------------------- /git-fire: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # Setup. 4 | VERSION="0.2.3" 5 | 6 | version() { 7 | printf "git-fire version %s\n" "$VERSION" 8 | 9 | git --version 10 | } 11 | 12 | # Helpers. 13 | current_branch() { 14 | basename "$(git symbolic-ref HEAD)" 15 | } 16 | 17 | current_epoch() { 18 | date +%s 19 | } 20 | 21 | user_email() { 22 | git config user.email 23 | } 24 | 25 | new_branch() { 26 | echo "fire-${1:-$(current_branch)}-$(user_email)-$(current_epoch)" 27 | } 28 | 29 | fire() { 30 | initial_branch="$(current_branch)" 31 | 32 | git checkout -b "$(new_branch)" 33 | 34 | # cd to git root directory 35 | cd "$(git rev-parse --show-toplevel)" 36 | 37 | git add -A 38 | 39 | if [ -z "$1" ]; then 40 | message="Fire! Branch $(current_branch)." 41 | else 42 | message="$*" 43 | fi 44 | 45 | git commit -m "$message" --no-verify 46 | 47 | for remote in $(git remote); do 48 | git push --no-verify --set-upstream "${remote}" "$(current_branch)" || true 49 | done 50 | 51 | if [ "$(git stash list)" != '' ]; then 52 | for sha in $(git rev-list -g stash); do 53 | git push --no-verify origin "$sha":refs/heads/"$(current_branch $initial_branch)"-stash-"$sha" 54 | done 55 | fi 56 | 57 | printf "\n\nLeave building!\n" 58 | } 59 | 60 | display_help() { 61 | cat <<-EOF 62 | 63 | usage: 64 | git fire [options] [COMMAND] [args] 65 | 66 | commands: 67 | git fire Add, commit, and push to remote in case of a fire 68 | git fire Execute git fire with for commit message 69 | 70 | 71 | options: 72 | -V, --version Output current version of git-fire 73 | -h, --help Display this help information 74 | 75 | EOF 76 | exit 0 77 | } 78 | 79 | 80 | case $1 in 81 | -V|--version) version; exit 0 ;; 82 | -h|--help) display_help; exit 0 ;; 83 | esac 84 | 85 | fire "$@" 86 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": { 3 | "name": "Nimit Kalra", 4 | "email": "me@nimit.io", 5 | "url": "http://nimit.io" 6 | }, 7 | "bin": { 8 | "git-fire": "git-fire" 9 | }, 10 | "bugs": { 11 | "url": "https://github.com/qw3rtman/git-fire/issues" 12 | }, 13 | "bundleDependencies": false, 14 | "deprecated": false, 15 | "description": "Save Your Code in an Emergency", 16 | "homepage": "https://github.com/qw3rtman/git-fire", 17 | "keywords": [ 18 | "git", 19 | "git-fire", 20 | "git", 21 | "fire", 22 | "emergency", 23 | "plugin", 24 | "extension" 25 | ], 26 | "license": "MIT", 27 | "name": "git-fire", 28 | "preferGlobal": true, 29 | "repository": { 30 | "type": "git", 31 | "url": "git+https://github.com/qw3rtman/git-fire.git" 32 | }, 33 | "version": "0.2.3" 34 | } 35 | --------------------------------------------------------------------------------