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

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

4 Comments

Thank you for your answer. Is the branch-specific git ignore a feature undere development ?
Be aware that if you merge that content you removed will be removed from master as well.
@evolutionxbox True, but the workflow will be development -merge> master -merge> "light". The only problem is that i will have to remove manually all docs/tutorials/examples for each merge
No, But yes this feature is required. It may come in play in future
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.

4 Comments

Thank you for your answer. I'm still learning git so i found a ressource about 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 ?
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 [email protected]:torvalds/linux.git Then you need to add it as a submodule to your branch. Checkout "pepito", then just git sibmodule add [email protected]:torvalds/linux.git eventually/the/path/where/you/want/it.
By "move ... to another branch", do you mean "move to separate (sub-)repositories"?
@roalz yes, another repository or sub repository, thanks

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.