1

I am trying to pull all the files and folders within a specific folder in my git repository. I have already tried using sparce-checkout but this pulls the specific folder. I wish for it to only pull the files within the folder.

I have a folder called /EWINS/ and I wish to pull every folder and file within that directory.

I have tried:

git init

git config core.sparseCheckout true

git remote add -f origin https://MYDIRECTORY

echo "EWINS/*" >> .git/info/sparse-checkout

git pull origin master

However this results in the folder EWINS being pulled where as I require all the items within EWINS.

I have referenced: How do I clone a subdirectory only of a Git repository?

http://lakehanne.github.io/git-sparse-checkout

Any help would be appreciated.

Community
  • 1
  • 1
Anthony Drury
  • 128
  • 2
  • 12

1 Answers1

1

As a previous stack-overflow-er has answered

This is called a sparse checkout, available since version 1.7.0.

"Sparse checkout" allows populating the working directory sparsely. It uses the skip-worktree bit (see git-update-index) to tell Git whether a file in the working directory is worth looking at.

While $GIT_DIR/info/sparse-checkout is usually used to specify what files are in, you can also specify what files are not in, using negate patterns. For example, to remove the file unwanted:

/*
!unwanted

See the linked answer and manual for details.

Community
  • 1
  • 1
Ben Hili
  • 135
  • 1
  • 9