- The CI/CD Guy
- Posts
- The CICD Guy Times - Issue #5 - 8 July 2025
The CICD Guy Times - Issue #5 - 8 July 2025
Who is Git's favorite child? Tilde or Carat
Your Weekly Dose of DevOps & Lifestyle
Explore →
📖 READ: 🔗Understanding GCP Load Balancers
🤓 FUN: You might be a DevOps engineer if... You've ever wished you could `git blame` real-life problems.
Think certifications are useless in today’s tech world? Here’s why they still matter for switching domains, upskilling, and staying relevant—plus how they can open doors you didn’t expect.
Who is Git's favorite child? Tilde or Carat
While working with Git, you might come across symbols like ^
(caret) and ~
(tilde) used with commit hashes to traverse the commit history. But what are these strange symbols, and how are they different?
In the next two minutes, let’s explore what these symbols mean and how they work.
But before we dive in, let’s test your understanding with a quick quiz:
Scenario:
You have two branches: main
and a feature branch fb
, which was created from main
at commit c2
. The feature branch is later merged back into main
, creating a merge commit c5
.

You are currently on the main
branch. What will be the output of the following commands?
git show HEAD~1
Options: c3, c4git show HEAD~2
Options: c2, c4git show HEAD^1
Options: c4, c3git show HEAD^2
Options: c2, c4git show HEAD^3
Options: c2, c1
Correct Answers:
c3
c2
c3
c4
Error
If you got all the answers right, you’re in great shape—but feel free to read on for a quick refresher. If you missed any, I highly recommend going through the rest of the article to strengthen your understanding!
The tilde (~
) and caret (^
) symbols in Git are both used to navigate your commit history, but they serve slightly different purposes and are especially useful in different scenarios.
Tilde (~): Linear Traversal
The tilde (~) is used to linearly traverse the commit history by referencing the first parent of each commit. In other words, it lets you move backward along the main line of development (the current branch’s direct history).
HEAD~
orHEAD~1
refers to the commit immediately beforeHEAD
.HEAD~2
refers to two commits beforeHEAD
.HEAD~3
refers to three commits beforeHEAD
, and so on.
Example:
Let’s explore the test scenario example only. Say you are on main branch.

HEAD~1
points toc3
HEAD~2
points toc2
HEAD~3
points toc1
This is especially useful when you want to quickly reference a commit a certain number of steps back from your current position, following only the first parent (which is important in branches with merge commits).
Caret (^): Parent Selection, Especially for Merge Commits
The caret (^) is also used to refer to parent commits, but it’s particularly important when dealing with merge commits, which have more than one parent.
HEAD^
orHEAD^1
refers to the first parent of the current commit (usually the branch you were on when you merged).HEAD^2
refers to the second parent of the merge commit (the branch that was merged in).If a commit has more than two parents (rare, but possible with octopus merges), you could use
HEAD^3
,HEAD^4
, etc., but for most merges, only^1
and^2
are relevant.
Example:
Again using the same example, assuming we are on main branch.

Since we have a merge commit c5
(HEAD) with two parents: c3
(main branch) and c4
(feature branch).
HEAD^1
points toc3
(main branch, the branch you merged into)HEAD^2
points toc4
(feature branch, the branch you merged from)HEAD^3
would result in an error unless there’s a third parent (which is uncommon)
Key Differences and Tips
Use tilde (
~
) for linear navigation along the main branch history, regardless of whether there are merge commits.Use caret (
^
) when you need to specifically reference a parent of a merge commit, especially if you want to see the history of a branch that was merged in.You can combine these: for example,
HEAD~2^2
means “the second parent of the commit two steps before HEAD.”
In summary:
Tilde (~) = Go back N commits in a straight line.
Caret (^) = Pick a specific parent (useful for merges).