git克隆某个分支到本地指定的目录中
通过git clone命令可以将远程git仓库拉取到本地。
如果想要只是拉取某个分支,并且将拉下来的代码放到指定本地目录中,使用如下的命令:
git clone --branch br01 http://172.20.58.152:8088/zhai01/test.git br01
参数释义:
--branch 指定分支的名字(br01)
br01:命令最后的br01是本地的目录名字,如果不指定就和仓库名字一样的目录,这里是test
执行过程:
[root@nctest-snap-test-02 apps]# git clone --branch br01 http://172.20.58.152:8088/zhai01/test.git br01
Cloning into 'br01'...
Username for 'http://172.20.58.152:8088': zhai01
Password for 'http://zhai01@172.20.58.152:8088':
remote: Enumerating objects: 23, done.
remote: Counting objects: 100% (23/23), done.
remote: Compressing objects: 100% (11/11), done.
remote: Total 23 (delta 6), reused 23 (delta 6), pack-reused 0
Unpacking objects: 100% (23/23), done.
查看本地目录
[root@test-snap-test-02 apps]# ls -l br01/
total 24
-rwxr-xr-x 1 root root 17 Jan 6 16:12 br01.sh
-rwxr-xr-x 1 root root 17 Jan 6 16:12 br02.sh
-rwxr-xr-x 1 root root 4 Jan 6 16:12 br03.sh
-rwxr-xr-x 1 root root 12 Jan 6 16:12 br04.sh
-rwxr-xr-x 1 root root 12 Jan 6 16:12 install.sh
-rw-r--r-- 1 root root 8 Jan 6 16:12 README.md
[root@test-snap-test-02 apps]#
已经将br01分支的内容放入到本地的br01目录中。
若有收获,就点个赞吧