Git – How to clone a specific directory from a Git repository

This post shows you 2 approach to clone a specific directory/folder from a Git repository.

For example, we want to clone the tools folder from the tensorflow git repository.

1. git checkout approach

git init
git remote add [REMOTE_NAME] [GIT_URL]
git fetch REMOTE_NAME
git checkout REMOTE_NAME/BRANCH -- path/to/directory
git init
git remote add tensorflow
git fetch tensorflow
git checkout tensorflow/master -- tools


2. svn checkout approach

In this approach, we need to replace tree/master with trunk in the following git url: and run the below SVN command:

svn checkout

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x