git new branch from commit doesn't checkout the code properly
I have a repo where my master has many commits… i want to create a new fresh branch from the first commit (the original code) so i do as follows:
git checkout -b mybranch 4589D6a09505837ec03b
4589D6a09505837ec03b is the first commit id… everything seems ok and now i’m at
mybranch. But I look at the code and it’s exactly the same thing as my
master! i even run my server from the new checkedout branch and it looks the same as
master. Maybe there’s something wrong with the id.. how can i ask github to pull the first ever commit from master?
EDITED: can I do this from a remote repo’s master branch instead? just branch that code into my local repo. I don’t want to recreate a repo for it.
One Solution collect form web for “git new branch from commit doesn't checkout the code properly”
What you want to do is:
git checkout 4589D6a09505837ec03b git checkout -b mybranch
From the man page on git checkout, when you put the commit id where you’re putting it, what you’re doing is telling git where to start the repository from, not where to end it, which is what I think you’re wanting to do. (If I’m wrong on my assumption there, let me know.)
Edit: These commands have the same behavior as the original question.