News

The Ultimate "git nah" Alias

Published
The Ultimate "git nah" Alias image

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 ⬇️
[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
fi
}

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!

Paul Redmond photo

Staff writer at Laravel News. Full stack web developer and author.

Filed in

Sponsored

laravelcloud logo
Laravel Cloud

Easily create and manage your servers and deploy your Laravel applications in seconds.

Visit Laravel Cloud

The latest

View all →
whereBinary(): Case-Sensitive MySQL Queries in Laravel image

whereBinary(): Case-Sensitive MySQL Queries in Laravel

Read article
Compile PHP to Native Binaries with TypePHP image

Compile PHP to Native Binaries with TypePHP

Read article
State of Laravel 2026 Survey Is Now Open image

State of Laravel 2026 Survey Is Now Open

Read article
Testing Best Practices Skill in Laravel Boost v2.6.0 image

Testing Best Practices Skill in Laravel Boost v2.6.0

Read article
Query Binding Masking and whereBinary() in Laravel 13.27 image

Query Binding Masking and whereBinary() in Laravel 13.27

Read article
Laravel AI: Load Tools On Demand With ToolSearch image

Laravel AI: Load Tools On Demand With ToolSearch

Read article