如何从服务器里面提取文件,如何从Git中的服务器存储库中提取单个文件?

本文介绍了一种使用 Git 的 Sparse Checkout 功能来初始化并同步指定文件夹的方法。通过执行批处理脚本,用户可以在本地克隆 GitHub 上的大型仓库时仅获取所需的部分文件夹,从而节省磁盘空间和下载时间。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

C:\Users\user name\Desktop>sparse_checkout.bat

C:\Users\user name\Desktop>pushd "C:\Users\user name\Desktop\"

C:\Users\user name\Desktop>if not exist .\ms-server-essentials-docs

mkdir .\ms-server-essentials-docs

C:\Users\user name\Desktop>pushd .\ms-server-essentials-docs

C:\Users\user name\Desktop\ms-server-essentials-docs>git init

Initialized empty Git repository in C:/Users/user

name/Desktop/ms-server-essentials-docs/.git/

C:\Users\user name\Desktop\ms-server-essentials-docs>git remote add

origin -f https://github.com/MicrosoftDocs/windowsserverdocs.git

Updating origin remote: Enumerating objects: 97, done. remote:

Counting objects: 100% (97/97), done. remote: Compressing objects:

100% (44/44), done. remote: Total 145517 (delta 63), reused 76 (delta

53), pack-reused 145420 Receiving objects: 100% (145517/145517),

751.33 MiB | 32.06 MiB/s, done. Resolving deltas: 100% (102110/102110), done. From

https://github.com/MicrosoftDocs/windowsserverdocs * [new branch]

1106-conflict -> origin/1106-conflict * [new branch]

FromPrivateRepo -> origin/FromPrivateRepo * [new branch]

PR183 -> origin/PR183 * [new branch]

conflictfix -> origin/conflictfix * [new branch]

eross-msft-patch-1 -> origin/eross-msft-patch-1 * [new branch]

master -> origin/master * [new branch] patch-1

-> origin/patch-1 * [new branch] repo_sync_working_branch -> origin/repo_sync_working_branch * [new branch]

shortpatti-patch-1 -> origin/shortpatti-patch-1 * [new branch]

shortpatti-patch-2 -> origin/shortpatti-patch-2 * [new branch]

shortpatti-patch-3 -> origin/shortpatti-patch-3 * [new branch]

shortpatti-patch-4 -> origin/shortpatti-patch-4 * [new branch]

shortpatti-patch-5 -> origin/shortpatti-patch-5 * [new branch]

shortpatti-patch-6 -> origin/shortpatti-patch-6 * [new branch]

shortpatti-patch-7 -> origin/shortpatti-patch-7 * [new branch]

shortpatti-patch-8 -> origin/shortpatti-patch-8

C:\Users\user name\Desktop\ms-server-essentials-docs>git config

core.sparseCheckout true

C:\Users\user name\Desktop\ms-server-essentials-docs>(echo

EssentialsDocs ) 1>>.git\info\sparse-checkout

C:\Users\user name\Desktop\ms-server-essentials-docs>git pull origin

master

From https://github.com/MicrosoftDocs/windowsserverdocs

* branch master -> FETCH_HEAD

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值