Why is there a difference between `master` and `heads/master`?
问题 I'm writing a shell script which switches to a specified commit, makes a copy of the index in /tmp , resets HEAD to original position, then runs a command in the temporary directory: orig_head=$(git rev-parse -q HEAD) # "refs/heads/master" git checkout "$1" # copy index to /tmp/... git checkout "$orig_head" # run command in /tmp/... However, this script gives me the same "'detached HEAD' state" message as when I run git checkout refs/heads/master : Note: checking out 'refs/heads/master'. You