Since I am in the process of making most of my programs available on github, I have been re-shuffling the some git repositories. Especially my collection of scripts (small programs for different purposes). Because some of those scripts are private, I don’t want to publish that repository as a whole.
The easiest way to do that would be to just copy the files into a new repository and commit them. But that would throw away the whole commit history of the files in question, which I don’t want to do.
Initially I thought that reposurgeon might do the trick.
After practicing with it, I came to the conclusion that it didn’t work all
that well for this purpose. To end up with only the files I wanted, I had to
expunge all other files. That is a lot of work. So I was using the wrong
tool for the task at hand. The fact that reposurgeon crashed a lot when doing
this didn’t help.
Since reposurgeon uses the command streams generated by git fast-export, I decided to stick with git’s fast-export and fast-import.
As an example, the way I isolated all scripts related to git into a new repository is shown below.
The following command was used to export the histories of the files in question;
git fast-export HEAD -- *git* kw* update-* > ../gitscripts.fi
Then I created and initialized a new repository and imported the history of those files;
mkdir git-scripts cd git-scripts/ git init git fast-import <../gitscripts.fi git checkout master echo '*.pyc' >.gitignore echo '*.pyo' >> .gitignore echo '__pycache__/' >> .gitignore echo 'backup-*' >> .gitignore git add .gitignore git commit -m "Added gitignore file."
For comments, please send me an e-mail.
- Convert RCS history to git
- Removing big files from git history
- Moving scripts to a private repo
- Keyword expansion with git
- Initializing a new git repo for a project