Getting Started Git Basics History and HEAD
History and HEAD
Understand Git history, HEAD, and how your current branch or commit relates to the commit graph.
Git history is the chain of commits for a repository, and HEAD refers to your current position in that history.
These two ideas are fundamental in Git because almost every action involves either moving through history or adding new commits to it.
What Git history is
Git history is the record of the commits saved in a repository over time.
Each commit records a project state and usually points to one parent commit. The first commit has no parent, and a merge commit has two or more. When branches are involved, the history is better understood as a graph rather than one simple straight line, but it is still helpful for beginners to think of it as a sequence of saved project states.
History helps you:
- See what changed over time.
- Understand when a change was introduced.
- Compare older and newer versions of the project.
- Move back to an earlier commit if needed.
What HEAD means
HEAD is Git's name for your current position in the repository history.
Most of the time, HEAD points to the branch you currently have checked out. That means new commits are added to that branch, and HEAD moves forward with it.
For example:
A --- B --- C main
^
HEADIn this example, HEAD is on main, and main points to commit C.
HEAD and the current branch
When you switch branches, HEAD moves to the branch you checked out.
Before switching:
A --- B --- C main
\
D --- E feature
^
HEAD
After switching to main:
A --- B --- C main
^
HEAD
\
D --- E featureThat is why changing branches can change:
- Which commit you are looking at.
- Which files appear in the worktree.
- Which branch new commits will extend.
This is also why HEAD is often described as "where you currently are" in the repository.
Detached HEAD
Sometimes HEAD points directly to a commit instead of a branch. This is called a detached HEAD state.
That can happen if you check out a specific commit rather than a branch tip.
Detached HEAD is not automatically wrong or dangerous, but it does mean new commits you make there are not attached to a normal branch name unless you create one.
History and HEAD in GitComet
GitComet helps you see both the repository history and your current place in it.
That includes:
- The list or graph of commits.
- The current branch.
- The commit currently checked out.
- How your local branch relates to remote branches.
When you understand history and HEAD, many other Git actions become easier to reason about, especially switching branches, rebasing, and resolving conflicts.
Filter and inspect history
GitComet offers history modes for everything reachable, first-parent history, no merges, merges only, and all branches. Use the author filter or the file history tab to narrow the results. Selecting a commit lets you inspect its files without checking it out. With the history list focused, Up / Down, PageUp / PageDown and Home / End move the selection.
Settings → Git log → Show graph gradient turns the lane-colored fade beside the graph on or off.
For changes between two points in history, use revision comparisons.
Commit signature badges
Signature verification is off by default, including after an upgrade, because it can slow down the Git log. Enable Settings → Git log → Verify commit signatures to check visible commits and the selected commit. GitComet asks Git to verify signatures using your local signing configuration; it does not verify offscreen history in the background.
Settings → Executables shows whether the required verifier is available: GPG for GPG/X.509 signatures, or ssh-keygen for SSH signatures. The signer's public key and any required trust configuration must also be available locally. SSH commit-signing configuration is separate from authenticating to an SSH remote.
| Badge | Meaning |
|---|---|
| Verified | Good signature from a trusted key. |
| Untrusted key | Good signature, but the key is not trusted locally. |
| Expired | The signature has expired. |
| Expired key | The signing key has expired. |
| Bad signature | The signature does not match the commit. |
| Revoked key | The signing key has been revoked. |
| No badge | Verification is disabled, the commit is unsigned, or verification could not complete, for example because a key or verifier is missing. |
After importing a key or changing trust, choose Settings → Executables → Recheck with verification enabled, or reopen the repository to refresh cached results. To inspect Git's result directly, run this inside the repository, replacing COMMIT with its SHA or revision:
git log -1 --format='%G? %GK %GS' COMMITReflog
The reflog records local movements of references, including branch switches and history rewrites. Open the command palette and choose Show Reflog to inspect these entries in GitComet's bottom panel.
A reflog can help you locate an earlier commit after a reset or rebase. It is local to your repository and is not a substitute for shared history or a backup.