当我在终端中看到本地存储库中带有 git 分支的分支时,它只打印一个,即 master
但是当我进入 gitlab 页面时,我有两个分支,分别是 main 和 master,默认情况下主分支是 main,但在 master 中我有所有更改
1 这是正常的吗?也就是说,在本地它有一个分支,在远程有两个
分支,我怎样才能煮它们?也就是说,要同步分支
3如何通过gitlab合并它们?
谢谢
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
发布评论
评论(1)
是的,当然,远程分支可能比本地分支多。想象一下,如果多个开发人员在一个存储库中工作,则并非每个分支都是每个开发人员的本地分支。仅将工作所需的分支下载到本地。
因此,首先,执行 git fetch ,将所有远程分支拉到本地存储库。使用 gitbranch -a 可以列出所有分支。
要合并分支,您可以通过命令行执行(要合并
main
中的master
,执行:git checkout master
,然后执行git merge main
) 或在 GitLab 中创建一个 合并请求。通常,存储库仅具有
main
或master
分支,但不能同时具有两者。广泛使用的是develop
/dev
- 除了main
/master
- 和feature-branches(主要用于较小的任务)。没有人告诉你分支策略,除非你想以 gitflow。
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. Withgit branch -a
you can list all branches.To merge the branches, you can do via command line (to merge
master
inmain
do:git checkout master
and afterwardsgit merge main
) or create in GitLab a Merge Request.Normally, a repository have only a
main
or amaster
branch, but not both. Widespread aredevelop
/dev
- in addition tomain
/master
- andfeature-branches
(mostely for smaller tasks). Nobody tells you a branch-policy, unless you want to work as example with gitflow.