Git - Current / working / HEAD / active branch


The current or active branch is:

  • The current branch is also known as the HEAD branch (in uppercase)
  • that represents the last commit known as the head (in lowercase) of the current branch

When a index (ie next commit) is created (ie the changes are commited):

  • the HEAD commit becomes the parent of the next commit (index).
  • and the committed index becomes the HEAD.



Local Repository

  • Output the current
git branch --show-current
  • The starred branch is the current branch
git branch
* branch-2.3
  • In the repository, you can see the head value of the HEAD in the HEAD file (the output shows that HEAD is a ref to the HEAD of the current branch)
cat .git/HEAD
ref: refs/heads/branch-2.3
  • Other command
git rev-parse --abbrev-ref HEAD

Remote Repository

You can see the HEAD branch with the following command

Example: below the head branch is master

git remote show origin
* remote origin
  Fetch URL:
  Push  URL:
  HEAD branch: master

The HEAD file is located at refs/remotes/<name>/HEAD

With a remote called origin, you would get the remote HEAD branch (ie default branch)

cat refs/remotes/origin/HEAD
ref: refs/remotes/origin/main

Change branch


You can change of active/current/working/HEAD branc with the checkout command


Sets or deletes the the default remote HEAD (ie local file refs/remotes/<name>/HEAD) with the command:

git remote set-head 

For instance:

git remote set-head origin main
# then push
  • to the remote default if it has changed
git remote set-head origin -a
# -a (or --auto) set the remote ''HEAD'' of the remote


origin/HEAD set to main

Powered by ComboStrap