In case of fire: GTFO 🔥
Intro
Hopefully this will never happen to you, but even if it's not a fire or earthquake, an emergency may arise and you are pressed to get out of the office/building and you have uncommitted code.
What do you need to do❓
GTFO: get-the-f-out ❗
Typically something along the lines of:
That's a lot of commands to write with a lot of potential for misspellings and having to retype them. I wrote this for fun and thought I would share it. There's two ways I did this: a git alias, a Mac .zsh or Powershell alias on top of the git command.
The result is being able to simply type g tfo
and having the computer take care of the rest of the work in saving your work and publishing to a remote branch for later recovery.
Aliases
So I first create the git alias by editing the .gitconfig
. I want to create an alias called tfo
and create a function that calls all the git commands I listed above in succession.
So here's what that looks like (normally 1 line, but wrapped for formatting):
✨ That's it! My repo now has a branch called emergency-exit
and I can merge or whatever I need to do later when it's safe.
To replace git
with just g
:
Powershell
Edit the .profile
to alias g
as git
.
Mac
Newer Macs use zsh
as the shell. Open the .zshrc
with nano or vscode.
Then update your terminal
💥 Now, I could write a global function called gtfo
that does everything, or even a script, but this was fast and easy and a nice little 10 minute break.
Important: If you are unlucky to have to do this more than once or you did this to test it out, the -B
in the command creates the branch if doesn't exist and if it does, then resets it with the new changes.
Also if you have to do this often... Stay the away from me...jk... But seriously... Don't come near me.