The Ultimate "git nah" Alias

Recently, developer Liam Hammett shared a fabulous git nah snippet on Twitter that is better than your existing git nah alias 🔥

I know lots of people use a "nah" alias to abort their current changes, but they usually limit it to "git reset --hard".

I like to do more by cleaning and aborting any potential rebase. If I use the "nah" command, I know I want a fresh start, so this helps

He shared two versions, including setting it up as a git alias:

# Git alias ⬇️
    nah = "!f(){ git reset --hard; git clean -df; if [ -d ".git/rebase-apply" ] || [ -d ".git/rebase-merge" ]; then git rebase --abort; fi; }; f"

If you prefer a bash function instead, here's that version that you would add to your .bashrc or .zshrch file:

# Bash function ⬇️
nah () {
    git reset --hard
    git clean -df
    if [ -d ".git/rebase-apply" ] || [ -d ".git/rebase-merge" ]; then
        git rebase --abort

Depending on which snippet you prefer, here's how you'd run it:

# Alias
$ git nah

# Bash
$ nah

What are some of your favorite git aliases? Share them with us!

The post The Ultimate "git nah" Alias appeared first on Laravel News.

Join the Laravel Newsletter to get all the latest Laravel articles like this directly in your inbox.

Read more

© 2024 Extly, CB - All rights reserved.