Moving files and keeping history / contributors

My aim is to create a new github repo, containing some files from a repo that I have forked (and then, because I’d already commited changes, effectively forked within my own github, using

I’ve found that in my repo, if I move files around so that they end up like I want them, the git history is removed (well, normally, and even when it isn’t, github doesn’t show the history until you go back to the parent commit - so all the people who actually did the work aren’t listed as contributors - which I’d really like to avoid). On the command line, I know that the full history is then shown with

git log --follow <file>

So, I tried doing a sparse checkout

git init
<set remote>
git fetch
git checkout origin/master -- python/

but this creates python/, rather than, which is what I need. I obviously can’t mv the file, because that has the same problem I found at the beginning.

I see two options, but haven’t found how to achieve either:

  • is there a way to save python/ into the current directory using git checkout or some other way I haven’t found? (git archive won’t work)
  • can I set a new remote URL from a subdirectory? i.e. cd into python and then set the remote so that only is committed into my repo?

I suspect what you’re looknig for is described in the solution on this topic.

Let me know if I’m not understanding.