Git branches are important to design. By convention your branches should reflect on your infrastructure. For example, if you have three different environments for development, staging and production then you should have three different branches ideally naming develop, staging and main. These three branches hold your team’s collaborative work and they should not be updated directly by anyone. There is a reason for that.

 

Imagine a scenario if you developed something on a develop branch and pushed it. One of your team members also updated but he didn’t pull your changes. If your team member pushes the code into the develop branch with the force option then your changes will be gone without a trace. 

To avoid this scenario, you always need to create your own branch update there and create pull requests to the develop branch from github. When you create your own branch, it’s a good practice to have a prefix on the branch's name. feature/, update/, fix/ and hotfix/ are common conventions. From the develop branch you should merge into staging and from staging to main. 

The flow look like this: feature/new_feature -> develop -> staging -> main

 

To ensure safety, configure repository settings to prevent direct pushes to these branches, avoiding accidental updates. Now, no matter who does what, you would never lose any changes ever.