DEV Community

Discussion on: I'm a Git Master, Ask Me Anything

Collapse
 
benaryorg profile image
#benaryorg

If I was to create a new branch and wanted it to be at exactly that commit, would I then use checkout for a detached head and then a checkout -b foobar?
Is there any better way to achieve this?

Thread Thread
 
gonedark profile image
Jason McCreary

You could do that.

Many forget checkout takes second argument as a reference to checkout from. So if your goal was simply to checkout a branch from an older point in time (commit abc123), you could run: git checkout -b foobar abc123