Skip to main content
  1. Learn center
  2. Software Development
  3. Guides
  4. Git tutorial
  5. Git collaboration
  6. Switching branches
  7. Pointing to branches
GuidesSoftware DevelopmentBacklog
Git

Project and code management together.

Pointing to branches

HEAD is used to represent the current snapshot of a branch. For a new repository, Git will, by default, point HEAD to the main branch. Changing where HEAD is pointing to will update your active branch.

The ~(tilde) and ^(caret) symbols point to a position relative to a specific commit. The symbols are used with a commit reference, typically HEAD or a commit hash.

  • ~ refers to ancestors (how many generations back depends on the number).
  • HEAD~1 refers to the commit’s first parent.
  • HEAD~2 refers to the commit’s first grandparent.
  • ^ refers to parents of merge commits.
  • HEAD^1 refers to the first parent of HEAD where head is a merge commit.
  • HEAD^2 refers to the first grandparent of HEAD where head is a merge commit.

A commit can have two parents in a merge commit.

Diagram of git symbols pointing to specific positions.
~(tilde) and ^(caret) symbols point to a position relative to the commit.

Subscribe to our newsletter

Learn with Nulab to bring your best ideas to life