Detached Heads
Learn how you can switch between different commits either in the same branch or across branches.
We'll cover the following
Sometimes when using Git you might have seen something like this:
git status
HEAD detached at 76d43b6
Detaching
The HEAD
pointer can be moved to an arbitrary point. In fact, git checkout
does exactly this. You can specify a reference (like master
or newfeature
) or a specific commit ID.
The next set of commands will check out the repository at a particular commit:
1 mkdir lgthw_git_branch_2
2 cd lgthw_git_branch_2
3 git clone https://github.com/ianmiell/shutit.git
4 cd shutit
5 git log
After running the above commands, you will see the log output in the terminal. Hit q
to exit the log output, and then run the following command to point the HEAD
pointer to a specific commit:
6 git checkout e36355ed00ac3af009d7113a9dd281c269a79afd
Get hands-on with 1400+ tech skills courses.