How to Clone a Specific Branch From a Git Repository
To clone a specific branch from a Git repository, you can use the following command:
git clone -b <branch-name> <repository-url>
// set custom folder name
git clone -b <branch-name> <repository-url> <folder-name>
Replace <branch-name>
with the name of the branch you want to clone and <repository-url>
with the URL of the Git repository you want to clone from.
Here's an example:
git clone -b development https://github.com/username/repository.git
This will clone the "development" branch from the specified repository. Make sure to replace username
with the actual username and repository.git
with the actual repository name.
If you're looking to clone a repository and then later switch to a different branch, you can use the following commands:
git clone <repository-url>
cd <repository-directory>
git checkout <branch-name>
Replace <repository-url>
with the repository URL, <repository-directory>
with the name of the directory created during the cloning process, and <branch-name>
with the name of the branch, you want to switch to.
Md Obydullah
Software Engineer | Ethical Hacker & Cybersecurity...
Md Obydullah is a software engineer and full stack developer specialist at Laravel, Django, Vue.js, Node.js, Android, Linux Server, and Ethichal Hacking.