I'd like to know if we use git checkout <commit hash> and the commit is in multiple branch, how do we know which one get checkout?
I didn't know how to do it visually so I tried to do a little drawing, sorry about that.
I'm not allowed to post it directly so here's a link.
If we have those three branches, then we git checkout <Commit Z>, will we get Branch A or Branch B?
How does it work? Thank you!
https://i.sstatic.net/Y3wJr.png
git checkout <commit> sets HEAD at this commit, regardless of any branches which might or might not point on said commit.
The working tree is updated accordingly, and you get what's called a detached HEAD. Further commits made from this point will indeed take HEAD as their parent, but no branch points to it until you create one (or make an existent one point here).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With