I added some files to the wrong repository and didn’t realize until later, once they already had quite a bit of history (just linear revisions, no branching or anything).
Is it possible to get these files and move them to another git repository together with their history? I don’t care if their remnants stay in their current one or not, as long as the new one has it all.
With
git log -p <filename> > <patchfile>(see doc) you can export the whole history of the file which can then be applied to the other repo viagit apply --reverse --index <patchfile>. However this does not recreate the commits, and I haven’t figured out the switch forgit-applyto do this.If you want to get rid of the file in the original repo, see “How do I remove sensitive files from git’s history?”.