title: Git checkout to new branch but HEAD is still from old branch
body: <p>I have code which do some checking( diff master with branch and diff HEAD^ HEAD) and if object in diff master with branch exist in diff HEAD^ HEAD do some stuff</p>
  <p>Code:</p>
  <pre><code>if ! [ -d $PROJECT/\.git ]; then
              echo &quot;Cloning project&quot;
              git clone $REPO $PROJECT
          fi
          
          #Fetch updates
          echo &quot;fetching updates&quot;
          git -C $PROJECT fetch --all
          strTmp=$(git -C $PROJECT diff origin/$BRANCH..origin/master --name-only)
          echo &quot;strTmp = $strTmp&quot;
  
          if [ -n &quot;$strTmp&quot; ]; then
                  
              git -C $PROJECT reset --hard
              git -C $PROJECT checkout $BRANCH
              git -C $PROJECT pull
              lastRev=$(git -C $PROJECT diff HEAD^ HEAD --name-only)
              
              array=(`echo $lastRev | sed 's/,/\n/g'`)
              changed=&quot;0&quot;
              for i in &quot;${!array[@]}&quot;
              do
                  echo &quot;$i=&gt;${array[i]}&quot;
                  if [[ $strTmp == *&quot;${array[i]}&quot;* ]]; then
                      changed=&quot;1&quot;
                      break
                  fi
              done
  </code></pre>
  <p>In one branch i found out this:</p>
  <p>**
  HEAD is now at 2c9db21e2</p>
  <p>Merge remote-tracking branch 'origin/master' into release/144</p>
  <p>Branch 'release/152' set up to track remote branch 'release/152' from 'origin'.</p>
  <p>Switched to a new branch 'release/152'</p>
  <p>Merge made by the 'recursive' strategy.</p>
  <p>_TUN.env             |  47 ++++++</p>
  <p>_TUN.dev            | 175 +++++++++++++++++++++</p>
  <p>_CLN.dev     |  57 +++++++</p>
  <p>3 files changed, 279 insertions(+)</p>
  <p>create mode 100644 _TUN.env</p>
  <p>create mode 100644 _TUN.dev</p>
  <p>create mode 100644 _CLN.dev</p>
  <p>0=&gt;_TUN.env</p>
  <p>1=&gt;_TUN.dev</p>
  <p>2=&gt;_CLN.dev
  **</p>
  <p>So we successfully switched to new branch release/152 but files ( and HEAD i think)still from release/144.</p>
  <p>And because of this script think nothing changed in this branch(changed=0).</p>
  <p>Question is why after we checkout to the new branch files still from old branch?</p>
  <p>Maybe i miss something?</p>