
Github collaboration usually requires creating multiple branches to manage different versions of the code then finally merging them to the main branch. Today's let's learn about how to create such branches and safe ways of merginging it to the main.
Let's assume that we plan to have our branch built like the below image where the highest level of branch besides the main is the 'pre-release' branch. Such branch is made to reduce the possibility of any problematic code to get pushed to the main branch.

In our case, we would like to go to the Pre-release branch.
First check which branch you are on:
git branch
git checkout Pre-release
Or
git switch Pre-release
⚠️ Don't forget to replace 'Sungju-feature2' with the name you want! ⚠️
git branch Sungju-feature2
After creating your local branch you need to connect this to a remote branch in order for other team members to see what you have been working on.
git push --set-upstream origin Sungju-feature2
As an example let's say Sungju is done with developing feature2 and has pushed it to her remote branch 'Sungju-feature2'. Now, she wants to push it to the 'Pre-release' branch so that it can get merged with other features that other people have developed.
In our case, we would like to go to the Pre-release branch.
First check which branch you are on:
git branch
git checkout Pre-release
Or
git switch Pre-release
git merge Sungju-feature2
git add .
git commit -m "merging feature2"
git push origin Pre-release
You will have to delete your branch twice: one you created locally, and another created remotely. Also, you cannot be on the branch you are deleting.
git branch -d branch_name
You can use the one below to forcefully delete in case of unmerged changes.
git branch -D branch_name
git push origin --delete branch_name