> From: Roy Vardi <roy.va...@gmail.com>
> How do I switch to a hash on a branch without creating\moving to a new
> Say I'm currently at the HEAD of master, and its hash is aaa.
> I want to stay on master, only switch to a previous hash... (say eee...)
> I know I can use the HEAD~<#> or whatever, but I'd like to find out how to
> do it based only on a hash...
It depends on exactly what you want to do.
If you want to set the files in your working directory to be the state
of a particular hash, you can do "git checkout <hash>".
However, there is the matter of Git's record of "what is currently
checked out". Normally, "what is currently checked out" (which is
stored in .git/HEAD) is (for example), "master". (Actually, "ref:
refs/heads/master".) That makes it possible to add a new commit to
the repository whose parent is the former value of "master", and
update "master" to be the new commit.
When you checkout a particular hash, you are in a state called
"detached head", in which "what is currently checked out" is just the
hash, and creating a new commit does not update any branch. (IIRC,
you have to provide a special option to git-commit to actually create
the commit, as normally one doesn't want to do that.)
You received this message because you are subscribed to the Google Groups "Git
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email
For more options, visit https://groups.google.com/groups/opt_out.