Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to git-pull all but one folder

Tags:

git

Is there any way to git pull all folders in the repository but one? I don't want to create a .gitignore file because other people may want the folder -- it's just too large for me to use right now.

Thanks!

like image 299
atp Avatar asked Mar 10 '10 12:03

atp


People also ask

Can I git pull a specific folder?

It's not possible. You need pull all repository or nothing.

How do I pull only a specific file in git?

git checkout origin/master -- path/to/file // git checkout <local repo name (default is origin)>/<branch name> -- path/to/file will checkout the particular file from the downloaded changes (origin/master).

How do I find a specific folder in a git repository?

Step1: Input github url to the field at the top-right. Step2: Press enter or click download for download zip directly or click search for view the list of sub-folders and files. Step3: Click "Download Zip File" or "Get File" button to get files.

What's the difference between git fetch and git pull?

Git Fetch is the command that tells the local repository that there are changes available in the remote repository without bringing the changes into the local repository. Git Pull on the other hand brings the copy of the remote directory changes into the local repository.


2 Answers

If you want to get just and you could:

mkdir <repo>
cd <repo>
git init
git remote add -f origin <url>
git config core.sparsecheckout true
echo <dir1>/ >> .git/info/sparse-checkout
echo <dir2>/ >> .git/info/sparse-checkout
echo <dir3>/ >> .git/info/sparse-checkout
git pull origin master

I found a good reference here.

like image 191
cforbish Avatar answered Oct 15 '22 15:10

cforbish


I don't think you can do partial pulling, but you can try and see what happen if you pull in a working tree which is not completely checked out.

Since Git1.7, you can do a sparse checkout, as illustrated here, meaning your working tree would explicitly exclude that specific folder when populate its content.

Now if that directory is that big, it may be better to isolate it in an autonomous Git repository, allowing other users to refer to it as a submodule.

like image 24
VonC Avatar answered Oct 15 '22 13:10

VonC