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.
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
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.