title: Git - moving back and forth and getting fatal: You are not currently on a branch?
body: <p>After moving backward and forward to trace a bug in my repo, eg:</p>
  
  <pre><code>$ git reset --hard fcf9818
  </code></pre>
  
  <p>Found the bug then I wanted to move forward to the latest commit, eg:</p>
  
  <pre><code>$ git checkout 32764bf   
  </code></pre>
  
  <p>Then, I started to make changes and want to commit it:</p>
  
  <pre><code>$ git status
  HEAD detached at 32764bf
  Changes not staged for commit:
    (use "git add &lt;file&gt;..." to update what will be committed)
    (use "git checkout -- &lt;file&gt;..." to discard changes in working directory)
  </code></pre>
  
  <p>I thought I am the latest commit already?</p>
  
  <p>But I went ahead to commit it:</p>
  
  <pre><code>$ git add -A
  $ git commit
  [detached HEAD ccf8009] Fixed gird bug on Safari - removing bootstrap grid css. Added code to centralise the image.
   2 files changed, 6 insertions(+), 1 deletion(-)
  </code></pre>
  
  <p>Now I have this error:</p>
  
  <pre><code>$ git push
  fatal: You are not currently on a branch.
  To push the history leading to the current (detached HEAD)
  state now, use
  
      git push origin HEAD:&lt;name-of-remote-branch&gt;
  </code></pre>
  
  <p>What should I do it properly then if I want to forward to the latest commit after going backward?</p>
  
  <p>How can I fix the error now?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <pre><code>$ git checkout 32764bf
  Warning: you are leaving 1 commit behind, not connected to
  any of your branches:
  
    6015d59 Fixed gird bug on Safari - removing bootstrap grid css. Added code to centralise the image.
  
  If you want to keep it by creating a new branch, this may be a good time
  to do so with:
  
   git branch &lt;new-branch-name&gt; 6015d59
  
  HEAD is now at 32764bf... Added template for finally - only image.
  </code></pre>
  
  <p>And I still getting <code>HEAD detached at 32764b</code>:</p>
  
  <pre><code>$ git status
  HEAD detached at 32764bf
  nothing to commit, working tree clean
  </code></pre>