0

first of all, thank you in advance for your help.

I'm not an expert on git so this is why I'm here...

I'm a developer of a driver in a embedded environment written in C. I want to work with two different driver structures and use git for svc.

For development (branch development) (in this case the driver is developed in "stand alone" mode, with: unit test, build, ecc..):

build\
        object files.o
        project.map
        project.srec
        project.lst
config\
        configuration1.h
        configuration2.h
driver\
        src1.c
        src2.c
        header1.h
test\
        other files
        ...
doc\
        documentation.pdf
makefile

for production (branch master) (in this case the driver is integrated in a project as submodule), and the project needs only the diver sources, headers and documentation:

driver\
        src1.c
        src2.c
        header1.h
doc\
        documentation.pdf

So, for production we don't want to see all directories or files that are only useful during development phase...

Now my questions:

is it possible to have two branches where the project is structured in that ways ?

is a correct style of work ?

Any suggestions?

Thank you,

Claudio

lonejack
  • 17
  • 1
  • 3
  • 1
    See..... _in the working tree_? Did you consider using `git sparse-checkout`? So, you want to build for production and there's no point in checking out the whole project, right? Then use `git sparse-checkout` and checkout only what s necessary. No hassle. https://git-scm.com/docs/git-sparse-checkout – eftshift0 Aug 12 '22 at 16:33
  • What do you mean by "for production"? Are those files distributed together with the executable? – axiac Aug 12 '22 at 16:52
  • The `build` directory and any other files generated during compilation or development should not stay in the repository. They should be added to `.gitignore`. `documentation.pdf` should also probably be ignored (it depends how it is produced). – axiac Aug 12 '22 at 16:53

1 Answers1

0

Question resolved by method indicated by [Tyrone Wilson] in How to git-cherry-pick only changes to certain files?

That is:

git checkout <other_branch_name> <files/to/grab in/list/separated/by/spaces> -p

In my case, when I modify some files on develop branch and want to apply variation on those files interested on master, it is necessary do:

git checkout master
git checkout develop driver/* -p
git commit -m "..."

lonejack
  • 17
  • 1
  • 3