'Different branches in repositories

When I see my branches in a local repository with git branch in the terminal it prints only one, which is master But when I go to the gitlab page I have two branches that are main and master, the main branch by default is main but in master I have all the changes

1 is this normal? that is to say, that in local it has a branch and in remote two

2 how can I just cook them? that is, to have the branches synchronized

3 how can I merge them through gitlab?

Thank you



Solution 1:[1]

Yes of course, it is possible, that on remote more branches exists then local. Imagine if several developers work in a repository, not every branch is also local by every developer. Only the needed branches to work are downloaded local.

So at first, do a git fetch, to pull all the remote branches to your local repository. With git branch -a you can list all branches.

To merge the branches, you can do via command line (to merge master in main do: git checkout master and afterwards git merge main) or create in GitLab a Merge Request.

Normally, a repository have only a main or a master branch, but not both. Widespread are develop/dev - in addition to main/master - and feature-branches (mostely for smaller tasks). Nobody tells you a branch-policy, unless you want to work as example with gitflow.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1