You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

无法克隆GitHub仓库:如何获取指定仓库的克隆URL?

How to Clone the Correct Repository for the Angular-CSharp SPA Template

Hey there,

The issue you're running into is that the URL you're trying to clone points to a specific subdirectory within a GitHub repository, not the repository itself. GitHub doesn't let you directly clone a single subdirectory—you need to either clone the entire repo first, or use a more advanced Git feature called sparse checkout if you only want that specific folder. Let's walk through both options:

Option 1: Clone the Entire Repository (Simplest Approach)

This is the easiest way if you don't mind downloading the full repo contents:

  • First, grab the actual clone URL for the aspnet/templating repo. On the repo's main GitHub page (just remove the /tree/dev/... part from your original URL), click the "Code" button in the top right corner, then copy either the HTTPS or SSH URL. The HTTPS one looks like this:
    https://github.com/aspnet/templating.git
    
  • Open your terminal or command prompt, run this command to clone the whole repo:
    git clone https://github.com/aspnet/templating.git
    
  • Once cloning finishes, navigate into the repo folder:
    cd templating
    
  • Switch to the dev branch (since your target directory is under the dev branch):
    git checkout dev
    
  • Finally, jump to the Angular-CSharp template directory you need:
    cd src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/Angular-CSharp
    

Option 2: Sparse Checkout (Only Download the Target Directory)

If you want to save space and only get that specific subdirectory, use Git's sparse checkout feature:

  • Create a new folder for your template and initialize an empty Git repo:
    mkdir angular-csharp-template && cd angular-csharp-template
    git init
    
  • Enable sparse checkout in the repo:
    git config core.sparseCheckout true
    
  • Tell Git which path you want to fetch:
    echo "src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/Angular-CSharp/*" >> .git/info/sparse-checkout
    
  • Add the remote repository:
    git remote add origin https://github.com/aspnet/templating.git
    
  • Pull the contents from the dev branch:
    git pull origin dev
    

Either way, you'll end up with the Angular-CSharp template files you're looking for!

内容的提问来源于stack exchange,提问作者Unknown developer

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 07:49:30