Merging Changes from Staging to Live Branch in Bitbucket

27 Views Asked by At

I have two branches in Bitbucket: 'live' and 'staging'. The main project for the live website is in the 'live' branch. I've added a new feature locally and pushed it to the 'staging' branch.

My question is: How can I move the changes from the 'staging' branch to the 'live' branch and merge both branches together? What's the best way to do this?

I attempted to add a new feature to my website project by implementing it locally and pushing the changes to the 'staging' branch on Bitbucket. Now, I need to integrate these changes into the main 'live' branch to make them accessible on the live website. I'm seeking guidance on the best approach to merge the changes from the 'staging' branch into the 'live' branch effectively while ensuring the stability and integrity of the project.

2

There are 2 best solutions below

3
Schwern On

You want staging to be as close to live as possible. Then you know when staging has passed an automated test suite with full coverage, live will work.

  • They use exactly the same code.
  • They use the same versions of the same services.
    • To avoid affecting each other, they use different accounts or different instances.

To guarantee this...

  • Avoid commits to live.
    • Consider making live a tag on the staging branch.
    • Consider making staging a tag on the development branch.
  • If you hot patch live, it must be merged or cherry-picked back to development.
  • Configuration is stored in the environment not the code.

Changes to persistent data are done with data and schema migrations which are also tested on staging before being deployed to live.

You could do this manually, but you should take advantage of BitBucket Pipelines to do this for you.

3
Anthony Nguyen On

Create pull request to 'live' branch. Then review and merge it.

The simple workflow for your case is:

  • Develop on feature branch then push to remote (bitbucket)
  • Create pull request from feature branch and merge to 'staging'
  • Create pull request from 'staging' to 'live'

Do not merge with reverse order.

The workflow I usually use is: feature, develop and main branch (the same as below but different names)