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?
I build things with my hands. The human behind Shift - https://laravelshift.com, master of Git - https://gettinggit.com, and author of "BaseCode" - https://basecodefieldguide.com
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
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
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 acheckout -b foobar
?Is there any better way to achieve this?
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 (commitabc123
), you could run:git checkout -b foobar abc123