What HEAD~1 means in git

calendar_today timer Reading time ~1 minute

Everyone types HEAD~1 in git. Do you know what that means?

HEAD is the pointer to the commit you are on. The ~1 means go one commit back. So HEAD~1 is the commit right before the current one. HEAD~2 is two commits back, and so on.

That’s how reset knows how far to rewind. It’s a small thing that makes git click.

Want the full reset walkthrough? I covered HEAD and reset here: Undoing the last commits using git reset

Follow for more git tips like this!

animated jess' signature

Related Articles