You can think of the HEAD as the “current branch”. When you switch branches with git checkout
, the HEAD revision changes to point to the tip of the new branch.
You can see what HEAD points to by doing:
cat .git/HEAD
In my case, the output is:
$ cat .git/HEAD
ref: refs/heads/master
It is possible for HEAD to refer to a specific revision that is not associated with a branch name. This situation is called a detached HEAD.
Related Contents:
- Find when a file was deleted in Git
- How do I delete unpushed git commits?
- How to compare a local Git branch with its remote branch
- .gitignore exclude folder but include specific subfolder
- What are some examples of commonly used practices for naming git branches? [closed]
- How to cherry-pick multiple commits
- What’s the best visual merge tool for Git? [closed]
- How do I clone into a non-empty directory?
- What does ‘–set-upstream’ do?
- How to undo local changes to a specific file [duplicate]
- Git submodule update
- How do I push to GitHub under a different username?
- How can I make Sublime Text the default editor for Git?
- How to search in commit messages using command line? [duplicate]
- How to amend older Git commit? [duplicate]
- How to modify a pull request on GitHub to change target branch to merge into?
- What does “Git push non-fast-forward updates were rejected” mean?
- how to remove untracked files in Git?
- Git: “Cannot ‘squash’ without a previous commit” error while rebase
- git: Apply changes introduced by commit in one repo to another repo
- Git: How to remove file from historical commit?
- Why should I use tags vs. release/beta branches for versioning?
- Git Ignores and Maven targets
- How to iterate through all git branches using bash script
- git pull aborted with error filename too long
- Git missing in VS Code – No source control providers
- Remove trailing whitespace on save in IntelliJ IDEA 12
- Deleting Files using Git/GitHub
- What are the big differences between TFVC (TFS Version Control) and Git for source control when using Visual Studio 2013?
- Git Bash: Could not open a connection to your authentication agent [duplicate]
- How can I fix git commit error “Waiting for your editor to close the file…” with VS Code?
- How to rename git root folder?
- Why doesn’t Git use more modern SHA?
- Ignore *all* whitespace changes with git-diff between commits
- How to disable git gpg signing
- What does a grey icon in remote GitHub mean
- How to git cherrypick all changes introduced in specific branch
- Ignoring folder meta files on version control
- How do I run git rebase –interactive in non-interactive manner?
- BitBucket: Host key verification failed
- How do you change the capitalization of filenames in Git?
- Git submodule URL not including username?
- How to count git commits per user in a date range?
- Gitignore all folders beginning with a period
- Ansible SSH private key in source control?
- What exactly is a merge conflict?
- How can I copy files from a branch to another using git?
- How can I change the default comments in the git commit message?
- Automatically delete git branch after merge to master
- How to combine two branches from two different repositories in a single repository?