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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,556,422
Community Members
 
Community Events
184
Community Groups

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

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.
Sep 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

Thanks Caroline

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

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.
Oct 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 

Suggest an answer

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

Atlassian Community Events