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

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


1 badge earned


Participate in fun challenges

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


Gift kudos to your peers

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


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!


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
Community Members
Community Events
Community Groups

How to set up git deployment to Staging and Production from BitBucket so they don't have working dir

We have a repo that contains 'develop' and 'master' branches among others. I have it set up so that I push new commits from my machine to the develop branch. I am currently the only developer but expect to have more in the future. I create a branch on my machine for a new feature, do the development, commit and merge that branch to develop on my machine and then push to develop in the Bit Bucket repo. I want to then push the code to our Staging server.

There should be no development on the Staging server so I don't need a working directory. I just want it simple - push the code to Staging and the changes are merged into the existing code. If some correction to the code in Staging is needed, that will be done in the original feature branch on my machine and committed, merged and and pushed to 'develop' on Bit Bucket and again pushed to Staging.

Likewise, once the code on the Staging server is verified, I need to merge the code into 'Master' from 'develop' and push to the Production server from 'Master' in a similar manner as I'm pushing to Staging. All simple and clean. 

A couple questions:

1. How to set up the git instances on Staging and Production servers for this scenario?

2. Production server code is an image from another machine and so it currently has a lot of "changes" both "modified" and "new". How do I convert this over from that to the set-up I'm talking about above? 

Note: This is a Laravel 8 framework with PHP 8 on Centos 8 machines.




1 answer

0 votes
Mark C Atlassian Team Feb 16, 2022

Hi @David Newey

Thank you for reaching out to the community.

For best practices, we do recommend managing your environments as branches within your repository.
In your case, you can have the following branches:

  • development
  • staging
  • production (or master)

The workflow would be: development > staging > production (or master)
If you want to have other branches (e.g. feature branches) you can merge them to the development branch first then continue the process.
For merging one branch to another, you can implement pull requests as well.

Now, when it comes to your servers, you can use Git and just simply clone your repository based on their environment.
For example:

  • For your Staging server, you can clone your repository and Git checkout to the staging branch
  • For your Production server, you can clone your repository and Git checkout to the production (or master) branch

After that, you can just do Git pull from your Staging or Production servers either manually or automatedly (e.g Using Bitbucket Pipelines) to get new updates.
Alternatively, you can also replace or overwrite a server's version using SSH or rsync commands just make sure you use the specific branch for the environment (staging or production). 

By doing this workflow, you can separate your Staging and Production servers based on repository branches.

Hope it helps and let me know if you have further questions.

Mark C

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events