Reputation: 14283
I've a git repo checked out on a server.
The repo used to have all the relevant files on the root, but i had to make some changes and now i have two folders, src
and dist
and i want to track both.
The problem i've got is that on my server, if i pull, i now have to navigate inside dist folder in order to see something.
I tried to search a bit and i think that what i'd like to do is called sparse-checkout.
I followed this tutorial: http://jasonkarns.com/blog/subdirectory-checkouts-with-git-sparse-checkout/, in particular the part that talks about an existing project and i did what mentioned:
but nothing happend. I mean, i still need to navigate to myproject/dist to being able to see something.
I also tried to cat sparse-checkout
file and dist/
is present.
I tried git pull origin master
as well, but with no luck.
Am i missing something here?
Upvotes: 2
Views: 9973
Reputation: 142054
You did everything as it should be.
sparse checkout
With sparse checkout you basically tell Git to exclude a certain set of files from the working tree. Those files will still be part of the repository but they won't show up in your working directory.
Internally, sparse checkout uses the skip-worktree
flag to mark all the excluded files as always updated.
# enable sparse checkout in an existing repository: git config core.sparseCheckout true # Create a .git/info/sparse-checkout file containing the # paths to include/exclude from your working directory. # Update your working directory with git read-tree -mu HEAD
Splitting a subfolder out into a new branch/repository
# use filter-branch to extract only the desired folder into a new branch
# once you done with your work you can always merge it back again.
git filter-branch --prune-empty --subdirectory-filter YOUR_FOLDER_NAME <branch>
# Filter the master branch to your directory and remove empty commits
Upvotes: 5