📌  相关文章
📜  来自特定分支命令的 git clone - Shell-Bash (1)

📅  最后修改于: 2023-12-03 15:40:21.386000             🧑  作者: Mango

Git Clone from Specific Branch Command

When cloning a Git repository, you may want to specify a particular branch to clone. This can be achieved using the following command:

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

For example, if you wanted to clone the develop branch of the my-project repository, the command would look like:

git clone -b develop https://github.com/my-username/my-project.git

This will clone the develop branch of the my-project repository into a new local directory named my-project.

If you do not specify a branch, Git will automatically clone the master branch by default.

You can also use the --single-branch flag to only clone the specified branch, ignoring all other branches.

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

This can be useful if you only need to work on a specific branch and want to save time and disk space by not cloning unnecessary branches.

In summary, the git clone command with the -b and --single-branch flags is a powerful tool for cloning a specific branch of a Git repository. Make sure to use it to your advantage in your Git workflow!