存储库中的不同分支

发布于 2025-01-11 08:06:08 字数 228 浏览 0 评论 0 原文

当我在终端中看到本地存储库中带有 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

陌上青苔 2025-01-18 08:06:08

是的,当然,远程分支可能比本地分支多。想象一下,如果多个开发人员在一个存储库中工作,则并非每个分支都是每个开发人员的本地分支。仅将工作所需的分支下载到本地。

因此,首先,执行 git fetch ,将所有远程分支拉到本地存储库。使用 gitbranch -a 可以列出所有分支。

要合并分支,您可以通过命令行执行(要合并 main 中的 master,执行:git checkout master,然后执行 git merge main) 或在 GitLab 中创建一个 合并请求

通常,存储库仅具有 mainmaster 分支,但不能同时具有两者。广泛使用的是 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. 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文