git clone and checkout in a single command

The following is the command I use to checkout a specific commit.

git clone git://repo.git/repo123
git checkout <commitID>

I want to do the above in one step – using a git clone command only.

  • Subversion: Check out only those files affected during a specific commit
  • What do git checkouts really mean?
  • Difference between checkout and export in SVN
  • GIT multiple local checkouts
  • Is it safe to checkout a new git branch during the push of a current branch?
  • Compare about using checkout or reset hard to undo git commit
  • The reason why I want to do this is, repo123 is very huge. So checking out the commit I want will save me a lot of time.

    I am aware of --depth option. But in this case, it is of no use. Can anyone tell me how to do it?

  • Unable to Git clone but can do a Git pull/push on already cloned repo
  • Try to svn checkout, but get: svn: '.' is already a working copy for a different URL
  • Group revisions together with Trac?
  • not valid: is this a git repository?
  • How to git svn clone full history despite svn copy
  • how to list all pull request with count of files changed
  • 3 Solutions collect form web for “git clone and checkout in a single command”

    git clone u://r/l --branch x
    

    still clones everything but sets the local HEAD to that branch so it’s the one checked out.

    Is your problem the checkout being to large or the repository itself?
    As git clone, well, clones a repository you usually get the whole repository in its full size. (unless you are doing a shallow clone as you already suggested.)

    If it’s really about the checkout of the wrong branch git help clone says:

       --no-checkout, -n
           No checkout of HEAD is performed after the clone is complete.
    

    After cloning with -n you can manually check out

    I was running into a same situation and it worked well with the Git Clone Command with --depth. And specify the branch-name/commit/Tag-Name at the end of the command with -b parameter.

    Syntax:

    git clone --depth 1 github.com:ORG-NAME/Repo.git -b <Branch-Name/Commit-Number/TAG>
    
    Git Baby is a git and github fan, let's start git clone.