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 http://deanmalone.net/post/how-to-fork-your-own-repo-on-github/
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/file.py
but this creates python/file.py, rather than file.py, 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/demo.py 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 file.py is committed into my repo?