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

  • Can I fork another persons repo twice into my own account?
  • How do you organise multiple git repositories, so that all of them are backed up together?
  • Git change history of feature-branch into a new branch?
  • DVCS with a Windows central repository
  • Combine color with conditional newlines in git log output
  • Git inserts junk meta tags inside the files after pull
  • 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.

  • Git Bash Open Command Windows
  • Can SVN do this branching model?
  • Gitignore exclude certain files in all subdirectories
  • Heroku Cannot GET /
  • git clone ends with Broken Pipe
  • The .git directory and security
  • 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.