2

I have a repository foo that contains a file Alice.js.

I want to take that file (that has lots of commits) and create a new repository only with the commits from that file.

How can I do this?


Example:

Initial repository

.
+- Alice.js
+- Bob.png
+- Another.file

do magic

New repository

.
+- Alice.js

The new repository contains only the commits from Alice.js.

Ionică Bizău
  • 109,027
  • 88
  • 289
  • 474

1 Answers1

1

You might want to try sparse checkout. The steps would be:

Create a empty repo with remote, as follows:

git init <repo>
git remote add -f origin <url>

Then, git config core.sparsecheckout true. Add files to checkout to .git/info/sparse-checkout.

And finally you can pull in the changes: git pull origin master.

nitishagar
  • 9,038
  • 3
  • 28
  • 40