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

why is there conflicts from a child branch even if there are no commits on parent

Ganesh Kumar August 20, 2018

I have three branches master, stage and dev. We create feature branches from dev( which serves as our integration env when deployed ). I have locked master and stage so that only merge can be done from lower branches( dev to stage/ stage to master ).

But some times when I create pull request from dev to stage it shows conflicts, even when there is no commit on stage. only way to move code to stage is pull request from dev.

1 answer

0 votes
Ana Retamal
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 22, 2018

Hi Ganesh!

You need to have your branches synced before attempting the merge. 

Looks like you are branching the local 'stage' branch before doing a pull from the remote repository for that branch. As a consequence, the local 'stage' is not in sync with the remote stage when the new branch (in this case 'dev') is created. 

When you try to merge 'dev' with the remote 'stage' branch you get conflicts because the branches were not synced.

In your situation it may be safer/easier to use git rebase: 

In general the way to get the best of both worlds is to rebase local changes you’ve made but haven’t shared yet before you push them in order to clean up your story, but never rebase anything you’ve pushed somewhere.

For more information, you can check Git Branching Rebasing.

As always, please take a backup of your repository before doing any changes.

So, to sum up, it would be: rebase locally, cleanup any conflicts locally and then push/merge with remote.

Hope that helps!

Ana

Ganesh Kumar August 22, 2018

HI Ana,

I come from github background but my current org uses bit bucket. I have been doing the same for last 3 years.

Master : Goes to production, Hence no commits possible on this.

Stage : Branch from master, Goes to QA, Hence no commits to this as well.

Dev : Branch from Stage. This belongs to Dev team hence commits are allowed on this.

Only way to move code from Dev to Stage is PR from DEV to Stage ( can be merged, Sqash/FF).

Similarly only way to move code from Stage to Master is PR from Stage to Master.

But this does not work. Stage is never ahead of dev but still it will show rubbish conflicts. Old code conflicting with new one. Same while pushing code from stage to master.

 

NOTE : No one in my team is allowed to commit to either stage or master. 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events