1

Background

My team has sub-teams working on modules of our application and dev work is on features of those modules. Our git branching strategy is: clean master --> dev branches for each in-progress-module --> feature branches:

master
|
+-+ module1-dev
| |
| +-- feature1A
| |
| +-- feature1B
|
+-+ module2-dev
  |
  +-- feature2A
  |
  +-- feature2B

When work on a feature is completed, it is merged into the module-dev branch. When the module-dev branch is completed, it is merged into the master branch. Time spent in a module-dev branch can be anywhere from 6 months to several years. Periodically, we'll merge the master branch into the dev branches.

Problem

We have a yaml file that should only exist within a dev-branch and its sub-branches. The yaml file will be different between the various module branches.

For example:

  • in master, foo.yaml contains ""
  • in module1-dev, foo.yaml contains "A B"
  • in module2-dev, foo.yaml contains "Y Z"

I want to see the same foo.yaml in module1-dev/feature1A and in module1-dev/feature1B which will have different contents from module2-dev/feature2A and module2-dev/feature2B. I should be able to change its contents in module2-dev/feature2B and merge into module2-dev, but I should not see the modified foo.yaml merged into master when that module eventually gets completed.

How can I ensure this in git? Is there a .gitignore, .gitattribute, or similar file that can be edited and committed as part of the repository? I am wanting to make this easy on each member of team, regardless of their git skill level.

Additional requirements:

  • This should not require personalized manipulation by each dev
  • This should not require editing when using the repository on a new computer (either replaced or because the user is new)
  • This should be able to work with the merge button in the BitBucket UI or other git UIs
Eric Poe
  • 383
  • 2
  • 9
  • Does this answer your question? [Using git, how do I ignore a file in one branch but have it committed in another branch?](https://stackoverflow.com/questions/1836742/using-git-how-do-i-ignore-a-file-in-one-branch-but-have-it-committed-in-another) – Christoph Apr 02 '20 at 15:00
  • @Christoph appreciate that find. A branch-based ignore file is what I was thinking of! The comments on that solution say that it no longer works with newer versions of git. I have edited my problem's description to better explain what I'm looking for. – Eric Poe Apr 02 '20 at 16:45

0 Answers0