Does HEAD always refer to what “master” refers to (in this context)?

Suppose one is on branch “master” and that HEAD is at the tip of the branch (say, on commit C). Suppose one then executes git reset --hard HEAD^3 back to commit A. Then HEAD now refers to A.

Question: Does “master” also refer to A, or is it still pointing at C? Put differently: in this context, does HEAD always refer to what the branch “master” does (i.e., assuming that our repository has only one branch named “master”)?

  • Using git to deploy to a cluster
  • How to handle backend (laravel) and frontend (angular) dependencies in different git repos
  • How do I fork an existing repo _of mine_?
  • How can I find what SVN branch my git branch will dcommit to?
  • Split Up Folders in a git repository into separate branches
  • rebar unable to get dependency from github
  • Difference between Git and libgit2
  • Check if current directory is a Git repository
  • How to setup a TAGS file (etags) for multiple git projects?
  • “Not a git repository” after OS reset
  • Remove weird 'Iconr' file from the repository
  • Git work flow with an inexperienced member
  • 2 Solutions collect form web for “Does HEAD always refer to what “master” refers to (in this context)?”

    Let’s check it, current branch is:

    $ git branch
    * master

    current state of the repo:

    $ git log --oneline
    e585b43 C
    4bbf8be B
    6ae7d39 A
    fb4949b Initial commit

    Let’s rebase it:

    $ git reset --hard HEAD~3
    HEAD is now at fb4949b Initial commit

    Let’s check where HEAD points:

    $ git log HEAD  --oneline
    fb4949b Initial commit

    Let’s check where master points:

    $ git log master --oneline
    fb4949b Initial commit

    As you can see HEAD and master point at the same commit

    No, HEAD will not always refer to the same commit as “master”.
    In case you checkout a commit that has been become dangling HEAD will refer to that commit and “master” will still refere to the tip of that branch.

    In this case will git reset --hard HEAD~3change HEAD and master to refer to the same commit.

    Git Baby is a git and github fan, let's start git clone.