Skip to content

Instantly share code, notes, and snippets.

@brettmillerb
Last active April 24, 2020 15:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brettmillerb/7b778cc4c36fc103165869b6968563df to your computer and use it in GitHub Desktop.
Save brettmillerb/7b778cc4c36fc103165869b6968563df to your computer and use it in GitHub Desktop.
Sparse-Checkout

Create a directory on your local machine

PS > New-Item -ItemType Directory -Name SharePointOnline-ScriptSamples

Directory: /Users/brett.miller/git/gitpersonal
Mode       LastWriteTime        Length Name
----       ------------ -       ------ ----
d----       24/04/2020  15:03          SharePointOnline-ScriptSamples

Initialise that repository

PS > cd ./SharePointOnline-ScriptSamples/

PS > git init
Initialized empty Git repository in /Users/brett.miller/git/gitpersonal/SharePointOnline-ScriptSamples/.git/

Add the git repo you want as the remote repository

PS > git remote add -f origin git@personal.github.com:Paddylabs/SharePointOnline-ScriptSamples.git
Updating origin
remote: Enumerating objects: 88, done.
remote: Counting objects: 100% (88/88), done.
remote: Compressing objects: 100% (85/85), done.
remote: Total 7154 (delta 37), reused 7 (delta 1), pack-reused 7066
Receiving objects: 100% (7154/7154), 16.05 MiB | 2.93 MiB/s, done.
Resolving deltas: 100% (4213/4213), done.
From personal.github.com:Paddylabs/SharePointOnline-ScriptSamples
* [new branch]      PowershellScripts-patch-1 -> origin/PowershellScripts-patch-1
* [new branch]      develop                   -> origin/develop
* [new branch]      master                    -> origin/master
* [new branch]      structure-fixes           -> origin/structure-fixes

Se the sparseCheckout setting in your git config for this particular repository

PS > git config core.sparseCheckout true

# The folder you want to checkout in the repository
PS > 'OTHER' | Set-Content .git/info/sparse-checkout

PS > cat ./.git/info/sparse-checkout
OTHER

Pull the files from the remote repository

PS > git pull origin master
From personal.github.com:Paddylabs/SharePointOnline-ScriptSamples
* branch            master     -> FETCH_HEAD

Only the OTHER folder is pulled because that's the only file listed in the sparse-checkout config.

PS > Get-ChildItem

    Directory: /Users/brett.miller/git/gitpersonal/SharePointOnline-ScriptSamples

    Mode                 LastWriteTime         Length Name
    ----                 ------------ - ------ ----
    d----          24/04/2020    15:05                OTHER
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment