Read Anthropic’s case study about Graphite Reviewer

What is HEAD in git?

Greg Foster
Greg Foster
Graphite software engineer


Note

This guide explains this concept in vanilla Git. For Graphite documentation, see our CLI docs.


HEAD is Git's pointer to the current branch or commit. Think of it as a bookmark, keeping track of where you are in your project's timeline.

Unlike traditional static bookmarks, HEAD moves as you interact with your repository, always pointing to the latest commit you're on.

Typically, HEAD points to the tip of your current branch. When you create or switch branches, HEAD adjusts its pointer accordingly.

In some scenarios, like during interactive rebases or when checking out a specific commit, HEAD can point directly to a commit instead of a branch, leading to a "detached HEAD" state.

Imagine the universe of your project, where each star is a commit. HEAD is like your spaceship, and as you navigate from star to star (commit to commit), it always shows your current position in this vast space.

  • To see where HEAD currently points, use git log --oneline --decorate -n 1.

  • If you find yourself in a detached HEAD state, don't panic! Create a new branch to save your position, or use git checkout to return to familiar territory.

Remember, HEAD is your navigation tool in the Git cosmos, always helping you understand your position in the project's history. Safe travels! 🌠

Git inspired
Graphite's CLI and VS Code extension make working with Git effortless.
Learn more

Graphite
Git stacked on GitHub

Stacked pull requests are easier to read, easier to write, and easier to manage.
Teams that stack ship better software, faster.

Or install our CLI.
Product Screenshot 1
Product Screenshot 2