Dan Matthews

Nah

Update: Chris Morrell on Twitter proposed an even safer option.

https://twitter.com/inxilpro/status/1762166776115105829

I noticed that Taylor Otwell on stage at Laracon EU 2024 used a "nah" shell command to clear everything he'd been doing, and I really liked it - a lot of the time i'm noodling around on the repo making or trying little changes and want to revert back to HEAD so i can pull changes my colleagues have made.

BUT, i wanted a bit more safety incase i typed it and wiped a whole bunch of changes, so i added a confirmation prompt:

nah() {
    echo -n "Are you sure you want to clear all changes in git? (yes/no): "
    read response
    if [ "$response" = "yes" ]; then
        echo "Resetting changes in git..."
        git reset --hard HEAD
        echo "Changes cleared successfully."
    else
        echo "Operation aborted."
    fi
}

# YOU (MIGHT) NEED THIS IF YOU AREN'T USING ZSH
alias nah = 'nah';

Just add this to your ~/.bashrc or ~/.zshrc file to use it.

And by popular demand, here's a little hellnah command you can use if you're sure you want to wipe everything without a confirmation:

hellnah() {
    echo "Resetting changes in git..."
    git reset --hard HEAD
    echo "Changes cleared successfully."
}

# YOU (MIGHT) NEED THIS IF YOU AREN'T USING ZSH
alias hellnah = 'hellnah';