git clone -b与git pull origin <branch_name>的区别

本文讲述了gitclone-b用于克隆指定分支,而gitpullorigin<branch_name>用于在已克隆仓库中获取并合并远程分支的最新更改。两者在Git分支操作中的不同用途和行为得以清晰阐述。

git clone -b 和 git pull origin <branch_name> 都是用于在 Git 中操作分支的命令,但它们有不同的用途和行为。

git clone -b

这是在克隆仓库时指定要克隆的特定分支的命令。它用于在克隆一个仓库的同时指定要克隆的分支。例如,如果你只想克隆一个特定分支的内容,可以使用以下命令:

git clone -b <branch_name> <repository_url>

这将克隆指定分支的内容到你的本地仓库,并在本地创建一个与该分支对应的跟踪分支。这在开始工作之前就把你的工作环境配置为特定分支的状态。

git pull origin <branch_name>

这是在已经克隆的仓库中更新特定分支的命令。它用于从远程仓库拉取指定分支的最新更改并将其合并到本地分支。如果你已经在一个仓库中,并且想要获取远程分支的最新更改,可以使用以下命令:

git pull origin <branch_name>

这将从远程仓库获取指定分支的最新提交,并将它们合并到你当前所在的本地分支。

总结:

git clone -b 用于在克隆时指定要克隆的分支。
git pull origin <branch_name> 用于从远程仓库获取特定分支的最新更改并合并到本地分支。
 

usage: git clone [<options>] [--] <repo> [<dir>] -v, --[no-]verbose be more verbose -q, --[no-]quiet be more quiet --[no-]progress force progress reporting --[no-]reject-shallow don't clone shallow repository -n, --no-checkout don't create a checkout --checkout opposite of --no-checkout --[no-]bare create a bare repository --[no-]mirror create a mirror repository (implies --bare) -l, --[no-]local to clone from a local repository --no-hardlinks don't use local hardlinks, always copy --hardlinks opposite of --no-hardlinks -s, --[no-]shared setup as shared repository --[no-]recurse-submodules[=<pathspec>] initialize submodules in the clone --[no-]recursive ... alias of --recurse-submodules -j, --[no-]jobs <n> number of submodules cloned in parallel --[no-]template <template-directory> directory from which templates will be used --[no-]reference <repo> reference repository --[no-]reference-if-able <repo> reference repository --[no-]dissociate use --reference only while cloning -o, --[no-]origin <name> use <name> instead of 'origin' to track upstream -b, --[no-]branch <branch> checkout <branch> instead of the remote's HEAD --[no-]revision <rev> clone single revision <rev> and check out -u, --[no-]upload-pack <path> path to git-upload-pack on the remote --[no-]depth <depth> create a shallow clone of that depth --[no-]shallow-since <time> create a shallow clone since a specific time --[no-]shallow-exclude <ref> deepen history of shallow clone, excluding ref --[no-]single-branch clone only one branch, HEAD or --branch --[no-]tags clone tags, and make later fetches not to follow them --[no-]shallow-submodules any cloned submodules will be shallow --[no-]separate-git-dir <gitdir> separate git dir from working tree --[no-]ref-format <format> specify the reference format to use -c, --[no-]config <key=value> set config inside the new repository --[no-]server-option <server-specific> option to transmit -4, --ipv4 use IPv4 addresses only -6, --ipv6 use IPv6 addresses only --[no-]filter <args> object filtering --[no-]also-filter-submodules apply partial clone filters to submodules --[no-]remote-submodules any cloned submodules will use their remote-tracking branch --[no-]sparse initialize sparse-checkout file to include only files at root --[no-]bundle-uri <uri> a URI for downloading bundles before fetching from origin remote 是什么意思
06-16
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值