What is HEAD in Git?
HEAD is a special pointer which tells Git where you are now. Usually it points to the current branch, and that branch points to its latest commit. When you make a new commit, the branch and HEAD move forward.
Terminal output
$ git log –oneline
f411fbd (HEAD -> main) Second
0057196 First
$ git show –oneline –no-patch HEAD~1
0057196 First
HEADis the current commit.HEAD~1(orHEAD^) is its parent,HEAD~2is two commits back.- If
HEADpoints to a commit and not a branch, it is called a detached HEAD.
Learn more about the similar topics:
| Tutorials |
|---|
| No Content Found. |
| Exercises & Assignments |
|---|
| No Content Found. |
| Interview Questions & Answers |
|---|
| No Content Found. |