You are not logged in.

#1 2020-05-10 18:01:24

cdwijs
Member
Registered: 2010-04-24
Posts: 185

Git: extract files from 2 git repositories, retaining the history.

Hi All,

I have one central repository with C subroutines that I use in micro controllers.

Then I make a new repository for each new project, and link to the above repository as a git submodule. The cool thing is that all projects I have can use the latest and greatest versions of the files in the central repository, the downside is that there's a lot of files in the working copy that are not used.

For example I have this in my central repository: A.c A.h B.c, B.h C.c C.h and so on.
In one project I only need projectOne.c and A.c and A.h
In the other project I have projectTwo.c and C.c and C.h.

When I want to publish projectTwo, I make a new repository, copy over projectTwo.c and C.c and C.h into a new git repository, and publish that. This way the history of all the files is lost.

Is there a way to prevent the loss of the history of the files?

Cheers,
Cedric

Offline

#2 2020-05-11 14:14:32

Awebb
Member
Registered: 2010-05-06
Posts: 5,428

Re: Git: extract files from 2 git repositories, retaining the history.

I don't know the exact answer to your question, but could git-sparse-checkout help you with your underlying problem?

Offline

#3 2020-05-11 21:56:08

bulletmark
Member
From: Brisbane, Australia
Registered: 2013-10-22
Posts: 459

Re: Git: extract files from 2 git repositories, retaining the history.

Just use one repository. As you start each project then create a new projectXXX branch and git rm the files you don't want there. There are a few advantages doing it this way. You can easily git merge project fixes and/enhancements back to your master branch, and or, to another project branch. You can rebase the entire project easily to a later master, etc.

Offline

Board footer

Powered by FluxBB