• Home
  • Ubuntu 20.04
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us
TecAdmin
Menu
  • Home
  • Ubuntu 20.04
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us

How to Clone Specific Git Branch from Remote Repository

Written by Rahul, Updated on April 4, 2019

This tutorial will help you to clone a specific git branch from the remote git repository via command line.

Syntax:

You need to specify the branch name with -b command switch. Here is the syntax of the command to clone the specific git branch.

git clone -b <BRANCH_NAME>  <GIT_REMOTE_URL>

Example:

The following command will clone the branch 5.1-branch from the WordPress git repository.

git clone -b 5.1-branch https://github.com/WordPress/WordPress.git

The above command clones only the specific branch but fetches the details of other branches. You can view all branches details with command git branch -a.

You can use --single-branch to prevent fetching details of other branches like below:

git clone -b 5.1-branch --single-branch https://github.com/WordPress/WordPress.git

All done. You can view the currently active branch by running the command:

git branch

Share it!
Share on Facebook
Share on Twitter
Share on LinkedIn
Share on Reddit
Share on Tumblr
Share on Whatsapp
Rahul
Rahul
Connect on Facebook Connect on Twitter

I, Rahul Kumar am the founder and chief editor of TecAdmin.net. I am a Red Hat Certified Engineer (RHCE) and working as an IT professional since 2009..

1 Comment

  1. Avatar Iron ThundeR Reply
    June 15, 2019 at 10:45 pm

    What’s up friends, pleasant paragraph and pleasant urging commented
    at this place, I am really enjoying by these.

Leave a Reply Cancel reply

Popular Posts

  • How To Install Python 3.9 on Debian 10
  • Download Ubuntu 20.04 LTS – DVD ISO Images
  • Linux Run Commands As Another User
  • How to Check PHP Version (Apache/Nginx/CLI)
  • How To Install and Configure GitLab on Ubuntu 20.04
  • How to Install PyCharm on Ubuntu 20.04
  • How to Check Ubuntu Version with Command or Script
  • How to Set all directories to 755 And all files to 644
© 2013-2021 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy