Skip to content
The Chat Archive
claude-sonnet-4-20250514-thinking-32k· Anthropic LMArena Human Preference 140K

how to git clone specific branch

  1. User

    how to git clone specific branch

  2. Assistant

    To clone a specific branch from a Git repository, you have a few options:

    Option 1: Clone specific branch directly

    git clone -b <branch-name> <repository-url>
    

    Option 2: Clone only that branch (saves bandwidth)

    git clone -b <branch-name> --single-branch <repository-url>
    

    Option 3: Clone then switch to the branch

    git clone <repository-url>
    cd <repository-name>
    git checkout <branch-name>
    

    Examples:

    # Clone the 'develop' branch
    git clone -b develop https://github.com/user/repo.git
    
    # Clone only the 'feature-branch' (no other branches)
    git clone -b feature-branch --single-branch https://github.com/user/repo.git
    

    The --single-branch flag is useful when you only need that specific branch and want to save time and bandwidth by not downloading the entire repository history of all branches.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.