title: Git: can I check out a commit without HEAD detached?
body: <p>From the Git manual:</p>
  
  <blockquote>
    <p>git checkout [--detach] &lt;commit&gt; Prepare to work on top of &lt;commit&gt;,
    by detaching HEAD at it (see "DETACHED HEAD" section), and updating
    the index and the files in the working tree. Local modifications to
    the files in the working tree are kept, so that the resulting working
    tree will be the state recorded in the commit plus the local
    modifications.</p>
  </blockquote>
  
  <p>It seems there is only one option: HEAD detached.
  Can I specify an option not let HEAD detached?</p>
  
  <p>[Upgrade 1]
  I asked a similar question in the comment in the post "<a href="https://stackoverflow.com/questions/4114095/revert-git-repo-to-a-previous-commit/4114122?noredirect=1#comment55086840_4114122">Revert Git repo to a previous commit</a>"</p>
  
  <pre><code># To get just one, you could use `rebase -i` to squash them afterwards
  # Or, you could do it manually (be sure to do this at top level of the repo)
  # get your index and work tree into the desired state, without changing HEAD:
  git checkout 0d1d7fc32 .
  
  # Then commit. Be sure and write a good message describing what you just did
  git commit
  </code></pre>
  
  <blockquote>
    <p>My Question to him: 
    @Jefromi, after "git checkout 0d1d7fc32 .", is the HEAD already
    detached? Then "git commit" cannot do anything with the dangled HEAD.</p>
    
    <p>to check out the state from 0d1d7fc32 in the current directory, but it
    leaves HEAD where it was. It's the same as using something like git
    checkout other-branch path/to/file - that will leave you on your
    current branch, and just check out the given file. In this case we're
    checking out the entire current directory instead of just one file,
    but still not changing HEAD. – Jefromi</p>
  </blockquote>
  
  <p>So it seems we can let HEAD not attached by adding "."</p>
  
  <p>[Update 2] From the answers and comments below, I think a neat one is:
  git reset --hard </p>
  
  <p>But then now my question is: 
  Is Jefromi's method correct?</p>
  
  <pre><code>git checkout 0d1d7fc32 .
  git commit
  </code></pre>
  
  <p>See the above link for more details of his method.</p>