Skip to content

Git merge impossible for big flows.json #2515

Description

@eitijupaenoithoowohd

What are the steps to reproduce?

Create two git branches for one Node-RED project and try to merge one big file flows.json from that different branches. Please note that this is not reproducing if flows.json file is small.

What happens?

Git does not try to merge files into one, just replacing one file with another.

I even know why that happens. It is because Node-RED save flows.json to git as one string without any formatting: EOL and any other delimiters. Just adding one EOF. I understand, that It is right for Node-RED to save JSON in compact view. But this creates a problem to git compatibility. Could you please provide an option (maybe managed through settings.js, for example) to save flows.json in formatted view for git?

What do you expect to happen?

git should see changed lines (like the "diff" tool) from different branches.

Please tell us about your environment:

  • [ ] Node-RED version: 1.0.2
    Reproduce in any other environment.

Activity

  1. changed the title [-]Git merge join impossible for flows.json[/-] [+]Git merge join impossible for big flows.json[/+] on Mar 23, 2020
  2. changed the title [-]Git merge join impossible for big flows.json[/-] [+]Git merge impossible for big flows.json[/+] on Mar 23, 2020
  3. knolleary commented on Mar 23, 2020

    @knolleary
    Member

    Are you referring to the Node-RED Projects feature with its build-in git handling? Or just managing flows files with git in general?

    In your settings file there is a setting called flowFilePretty which you can enable and set to true to cause it to format the flow file over multiple lines.

    I thought the Projects feature auto-enabled this feature regardless.

  4. eitijupaenoithoowohd commented on Mar 23, 2020

    @eitijupaenoithoowohd
    Author

    It happens when two different people work on the same Node-RED project using git as their code-repository for flows.json. Each person uses their git branch and would like to make merge when both shall finished.

    Thank you very much for the hint about flowFilePretty. I've try to find any option like that in the site's documentation, but found nothing. Maybe because the description is ambiguous and incomplete.

    I thought the Projects feature auto-enabled this feature regardless.

    Unfortunately, this is not the case.

  5. knolleary commented on Mar 23, 2020

    @knolleary
    Member

    Checking the code, I was wrong - Projects doesn't auto-enable the feature, although that is something that has been discussed, just never put into action.

    So, for your issue, flowFilePretty is the answer.

  6. eitijupaenoithoowohd commented on Mar 23, 2020

    @eitijupaenoithoowohd
    Author

    Thank you, Nick.

  7. added this to the 1.2 milestone on Jun 29, 2020
  8. gmag11 commented on Apr 8, 2024

    @gmag11

    Maybe making Node-Red to store separate files, at least for each flow, would make git management easier when doing merges between branches.
    Currently it is very easy to create merge conflicts.
    What do you think?

  9. beasteers commented on Sep 10, 2024

    @beasteers
    Contributor

    going further, using either yaml or (even safer) separate files for function code would let you do merges in multi-line strings.

    Using separate files for functions could let you just transparently resolve merge conflicts in the code editor.

  10. PaulWieland commented on Nov 11, 2025

    @PaulWieland
    Contributor

    I think this is a feature necessary for deploying NR in corporate environments where there are multiple contributors and larger and larger flow files.

    I think splitting the flows.json into one pretty file per tab would be a great start.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions