I have a project that started with a single directory. Then I added directories to it but structured the main project with subdirectories that matched sub-projects. One of these subdirectories is, say lib/
, which contains the common ground for all my projects based on the same architecture.
Since lib/
has become a project worth its own GIT (sub-)tree, I'd like to make it independent but I don't want to lose all the related commits I made while working in the main project. What I'd like is something that would be a copy of my main repository along with its entire commit history with everything stripped off but files in lib/
.
So I saw it can be done.
I must confess I do not always understand GIT jargon very well so, please, bear with me.
I did git clone -l <main project> lib
then I ran git filter-branch -f --prune-empty
from directory lib/
. I ran git status
and it told me the origin and this "branch" differ and I should run git pull
... Hmmm... I'm using only local repositories so I tried git remote rm origin
and the message went away. However I suppose there's a shortcut to avoid this, right?
Anyway, what I see in the log tree is now all commits... or stuff, whatever in triple:
$ git log --reflog --graph --oneline --decorate --date-order
* 880d3e8 Framework Library - Update
| * 2cfbb42 (refs/original/refs/heads/1.0) Framework Library - Update
| | * 578968f (HEAD -> 1.0) Framework Library - Update
* | | 65daea4 Tools: ECU simulator (new)
| * | 62981c7 Tools: ECU simulator (new)
| | * 9e4015d Build 423 - Makefile bugfixes and small changes
* | | 3eddb88 Build 423 - Makefile bugfixes and small changes
| * | 82b5ed1 Build 423 - Makefile bugfixes and small changes
* | | bb46ee9 Build 423 - Bugfixes
| * | 7cd40ac Build 423 - Bugfixes
* | | ab0058c Build 420 - Bugfixes
| * | 3f3257b Build 420 - Bugfixes
| | * 2f2184f Build 416 - Enhancements and fixes
* | | 39ea1de Build 416 - Enhancements and fixes
| * | 11c1f0f Build 416 - Enhancements and fixes
| | * 770d628 Build 406 - Enhancements
* | | 952f9a2 Build 406 - Enhancements
| * | f0c86c3 Build 406 - Enhancements
| | * 5b8cfef Build 405 - Bugfixes and enhancements
* | | 6c1b590 Build 405 - Bugfixes and enhancements
| * | 0e79341 Build 405 - Bugfixes and enhancements
...
Is that normal? How can I trim the redundant ones?
I'm working with local repositories only and am not planning shortly to use distant repositories. Well, unless I'm missing something, of course.
Oh, and I do have a backup. (If it were just one...)