Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to ignore yml and config files while merging one branch to another

Mukul Rana September 27, 2022

Hello Everyone,

I am facing this issue where when i merge my code from dev to stage pipeline , I get a merge conflict error on bitbucket-pipelines.yml and config.js. 

It is a requirement that these two files stay different in both pipelines as they contain configurations specific to them.

I have tried adding .gitignore file with entry of yml file and config.js directly into the repo through UI but that doesn't seem to help

I also tried applying .gitattributes by following this answer on stackoverflow: gitattributes 

but i still get the merge conflict.

 

Any help would be much appreciated.

Thanks in advanced!

 

 

1 answer

1 accepted

0 votes
Answer accepted
Caroline R
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 28, 2022

Hi, @Mukul Rana, welcome to the community! 

Before we start, I would like to further understand the configuration you have in your repository. Do you have 2 yml files under this repo? Also, when you say that you are facing an issue when you merge your code from dev to stage pipeline, is it triggering a default definition in your pipelines?

If that’s the case, you can actually have 1 YAML file under your repository and configure it to run specific sections for specific branches, this way, the names or expressions in this section are matched against branches in your Git repository. For example:

pipelines:
  default:
      - step:
          name: 'Build and Test'
          script:
            - echo "Your build and test goes here..."
  branches: #these will run on every push of the branch
    bug:
      - step: 
          script:
            - echo "I'm testing something here"

This document explains how to configure your bitbucket-pipelines.yml, in case you would like to take a look:

Looking forward to hearing from you. 

Kind regards,
Caroline

Mukul Rana October 3, 2022

Thanks Caroline

We were able to solve this issue by rewriting our yml files in the way you suggested!

Mukul Rana October 6, 2022

Hi ,

I missed an important part of the question. 

With the help of your suggestion, i was able to reorganise my yml files and avoid merge conflict however my config.js file still shows merge conflict error.

Let me tell you more about our current scenario

We have a config.js in our stage pipeline and in production. It is necessary that these two files remain different. However, when we merge stage to production, we get a merge conflict on this file.

Can you suggest a way by which when i merge these files remain in thier original state or if i can say - Are ignored while merging.

Thanks!

Caroline R
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 10, 2022

Hi, @Mukul Rana

This is not possible as Git does not allow this. However, while searching for workarounds, I found the same questions on other sites that might help you:

They recommend running git merge with the flag --no-commit to avoid specific files. 

I hope this helps, but let me know if you have questions. 

Kind regards,
Caroline 

Like Henrik Kristensen likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events