【问题标题】:How do I clone only a subdirectory of a Git repo?如何仅克隆 Git 存储库的子目录?
【发布时间】:2021-09-26 22:05:51
【问题描述】:

我尝试只克隆 Git 存储库 using this answer 的子目录,但它不起作用。

我使用 Ubuntu for Windows (WSL),并使用了以下命令:

$ git init
$ git remote add -f origin <repo-ssh>
$ git config core.sparseCheckout true
$ echo 'FolderName/' >> .git/info/sparse-checkout
$ git pull origin master
fatal: couldn't find remote ref master

$ git pull origin main
 * branch            main       -> FETCH_HEAD
Already up to date.

'FolderName/' 在这种情况下:'Exercise2/'

我不知道如何解决。

远程分支名称为main

【问题讨论】:

  • 'FolderName/' 在这种情况下:'Exercise2/'”是什么意思?你需要“修复”什么?请阅读How to Ask

标签: git ubuntu github windows-subsystem-for-linux


【解决方案1】:

你的问题有点模棱两可。 但我认为这应该可以解决您的问题:

git remote set-url origin https://github.com/your/repository

照常执行其余步骤。只需更改您的远程来源网址即可。

【讨论】:

    猜你喜欢
    • 2012-05-06
    • 1970-01-01
    • 2022-07-15
    • 2021-04-11
    • 1970-01-01
    • 2013-11-04
    • 1970-01-01
    • 2012-08-03
    相关资源
    最近更新 更多