0

I am currently working with -I suppose- a standard workflow :

  • Master branch : Stable code
  • Development branch : Development features
  • XXX branchs : new_features branch

With following workflow :

*--*--*--*--*--*--*--*--*--*--*- (master)
          \
            *--*--*--*--*--*--*- (development)
               \
                - *--*--*--*--*- (new feature X) 

My master branch includes documentation, examples and tutorials for all modules of my project

Project TOTO
  |
  |
  --- Module pepito 
  |     |
  |     ----Submodule alpha (src, docs, tutorials, examples)
  |     |
  |     ----Submodule beta (src, docs, tutorials, examples)
  --- Module pepita
  |     |
  |     ----Submodule gamma (src, docs, tutorials, examples)
  |     |
  |     ---- Submodule delta (src, docs, tutorials, examples)
  ---- Module pepiti (src, docs, tutorials, examples)

This workflow is fine, but i would like a new branch "light" without docs, tutorials and examples like this :

Project TOTO
  |
  |
  --- Module pepito 
  |     |
  |     ----Submodule alpha (src only)
  |     |
  |     ----Submodule beta (src only)
  --- Module pepita
  |     |
  |     ----Submodule gamma (src only)
  |     |
  |     ---- Submodule delta (src only)
  ---- Module pepiti (src only)

Since all my project have the same structure :

Main directory
 - src
 - docs
 - examples
 - tutorials

I would like to define a sort of "gitignore" that excludes pattern "docs", "examples" and "tutorials" when I merge from master to new "light" branch. Is it possible ?

I found some ressources like these : ignore a directory while merging or setupd a git driver to ignore a folder

But they don't fit my workflow (1st link) or seems to be an overkill (2nd link)

Is there a simple way to get the requested behavior or should I change my workflow ? Thank you

Community
  • 1
  • 1
Johann MARTINET
  • 94
  • 1
  • 10

2 Answers2

3

You can always create a branch from master say 'x' then you can remove the unwanted content and commit.

To make your work easy you could have thought of branch-specific git-ignore but this feature is not currently available in git

Your best bet is to create a branch and remove the unwanted content and commit.

1

I think a good solution would be to move documentation, examples and so on to another repository, and link it as a submodule only in those branch that need it.

ErniBrown
  • 1,283
  • 12
  • 25
  • Thank you for your answer. I'm still learning git so i found a ressource about [submodules](https://git-scm.com/book/en/v2/Git-Tools-Submodules). Your solution is good but it seems to break my project structure, I will have to put all documentations/examples/tutorials in the same folder to then link it to the master branch. Did I miss something ? – Johann MARTINET Feb 07 '18 at 08:28
  • Please note that my solution is pretty simple to implement in a new repository. If you want to modify the repository you already have the solution is a little more complex. First you need to create a new repository (or more than one) with examples, documentation, and everything else you don't want to include in every branch. let say its address is git@github.com:torvalds/linux.git Then you need to add it as a submodule to your branch. Checkout "pepito", then just `git sibmodule add git@github.com:torvalds/linux.git eventually/the/path/where/you/want/it`. – ErniBrown Feb 07 '18 at 09:49
  • By "move ... to another branch", do you mean "move to separate (sub-)repositories"? – roalz Aug 28 '18 at 10:27
  • @roalz yes, another repository or sub repository, thanks – ErniBrown Aug 29 '18 at 08:38