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

where 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.

  • Pushing changes to a specific remote branch in Git
  • How to share a branch with other developers under git
  • How can I quickly check which Git branch is the newest?
  • Unable to get git branch from puppet agent
  • How to make a new branch in Visual Studio 2015?
  • How do I rename my git 'master' branch to 'release'?
  • How could I mark a git branch as deprecated
  • What are some of the most common Git branching schemes/commit lifecycles?
  • 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.

    Git Baby is a git and github fan, let's start git clone.