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 https://github.com/tensorflow/tensorflow.git
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: https://github.com/tensorflow/tensorflow/tree/master/tools and run the below SVN command:

svn checkout https://github.com/tensorflow/tensorflow/trunk/tools

guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x