git - How can I checkout specific folder and its content from a specific commit to external folder? -


how retrieve complete subfolder git (version 1.7.0.4) repository local folder without checking out whole repo in first place? thought solution:

git --work-tree=/home/tmp/testcheckout checkout commitid -- images/*

example repo structure directories:

/git/project1/sourcecode   /git/project1/images   /git/project1/howto   /git/project1/readme.txt 

so example command should checkout files under /git/project1/images /home/tmp/testcheckout have been committed git repo commit commitid checks out files have been committed @ given commitid, ignoring other files have been committed before that.

problem:
command above files subfolder have been committed commitid.

question:
want retrieve files commitid. solution this?

important: don't want clone whole repository (700gb) able retrieve 1gb of files later. there must way directly files out of repo without cloning whole repo.

here working solution this. solution has following features:
- not checkout whole repo, checks out need (this comes in handy if have repos of 100gb , more) - create new repo target, nothing gets changed in original repo, nice ey?

solution

git init /example/gittest cd /example/gittest git remote add -f origin /path/to/source/repo/.git git config core.sparsecheckout true echo images >> .git/info/sparse-checkout git pull origin master 

now copies imagesfolder original repo test repo. can data want.


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -