GIT: Split file into multiple files, then detect changes in updated original file and apply to multiple files.

555 views
Skip to first unread message

skybuck2000

unread,
Nov 22, 2021, 7:31:21 PM11/22/21
to git-for-windows
GIT: Split file into multiple files, then detect changes in updated original file and apply to multiple files.

File Original contains:

ObjectA

Some funtions for Object A

some more functions for Object A

ObjectB

Some functions for Object B

some more functions for Object B

ObjectC

Some functions for Object C

some more functions for Object C


This should be split up into three files:

ObjectA

ObjectB

ObjectC


Such that File ObjectA contains:

ObjectA

Some funtions for Object A

some more functions for Object A


Such that File ObjectB contains:

ObjectB

Some funtions for Object B

some more functions for Object B


Such that File ObjectC contains:

ObjectC

Some funtions for Object C

some more functions for Object C


Later file Original is updated:

ObjectA

Some funtions for Object A

some more functions for Object A

even more functions for Object A

ObjectB

Some functions for Object B

some more functions for Object B

even more functions for Object B

ObjectC

Some functions for Object C

some more functions for Object C

even more functions for Object C


Is it somehow possible to use git to automate the updating of File ObjectA, File ObjectB File ObjectC so that all three files contain the new line such that:


Such that File ObjectA contains:

ObjectA

Some funtions for Object A

some more functions for Object A

even more functions for Object A


Such that File ObjectB contains:

ObjectB

Some funtions for Object B

some more functions for Object B

even more functions for Object B


Such that File ObjectC contains:

ObjectC

Some funtions for Object C

some more functions for Object C

even more functions for Object C


This is a scenerio where the original file is updated by a different user.

It would be very nice if a feature git had this detection capability for two reasons:

  1. Big teams/projects that might not want to freeze such a big fle.

  2. No-cooperating teams/repository that don't want to split the file.


Now that I understand git a little bit better, very maybe this will work:

What could be tried for the split dilemma, is the following idea:


1. The original document.txt is splitted in a "split commit" such that objecta.txt objectb.txt and objectc.txt exist.

2. This "split commit" can be isolated on top of original document.txt or anywhere basically.

3. Then when original document.txt is updated, try and reapply the "split commit", by basically re-basing it on top of the updated document.txt

So in git terms the idea is as follows:

BranchOriginalDocument   commit 1
    document.txt
BranchSplittedDocument     commit 2
    objecta.txt
    objectb.txt
    objectc.txt
    (could even be placed on their own sub branch if necessary because one branch might not be enough)
BranchUpdatedDocument    commit 3
    document.txt
    
now after after commit 3 is done, commit 2 could be rebased onto commit 3 in the hopes that git will recgonize the split operation and maybe
repeat it on top of document.txt with updated contents.

the git command for this would like something like:

git rebase --onto BranchUpdatedDocument BranchOriginalDocument BranchSplittedDocument

tomorrow I will give this a try to see how far I get with this.

If it fails one more try would be to create additional branches or so, I saw somebody mention in the past that that might work.
not sure if they should be based on each other, but maybe... or seperate branches could be tried as well, all based on branch splitted document.

BranchSplittedDocument
BranchA
BranchB
BranchC  
BranchUpdatedDocument

(I am not sure if I have tried this before, maybe, but I understand git rebase a little bit better now, and git in general ! ;))

Any suggestions are welcome !

Bye,
  Skybuck.

skybuck2000

unread,
Nov 30, 2021, 1:15:11 PM11/30/21
to git-for-windows
Split all at once so far not succeeded, individual branches offer some help, by allowing git -mv to indicate to git that a big file was renamed/reduced to a small file.

Then later all individual branches can be merged to produce a build.

The problem with this is if changes are done to  the new build, and later to old build, changes from new build get lost or have to be re-applied to individual branches again.

What I would need here is a way to tell git that a big file should be copied/applied multiple times to individual parts/files ?

So for example:

Apply BigFile to LittleFile1 LittleFile2 LittleFile3

(something to indicate to git that bigfile was split/renamed to multiple files, then at least I can do the merge conflicts when bigfile changed and have to re-apply changes to these files, recording to links from BigFile to LittleFiles would already be helpfull.)

There seem to be some git plumbing commands.

Maybe there is some plumbing command that can help with this.

Bye for now,
  Skybuck.
Reply all
Reply to author
Forward
0 new messages