git 在 Gitlab 中创建一个新分支

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13639980/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 15:00:28  来源:igfitidea点击:

Create a new branch in Gitlab

gitgitlab

提问by Bathakarai

I want to create a new work branch in gitlab. I want to be the admin of that branch. Please, someone help me learn how to create my own branch in Gitlab and keep my projects on that work branch...

我想在 gitlab 中创建一个新的工作分支。我想成为那个分支的管理员。请有人帮助我学习如何在 Gitlab 中创建我自己的分支并将我的项目保留在该工作分支上...

回答by psilocybin

From the command line:

从命令行:

git checkout -b <branch_name>

回答by Mchl

I think what you mean is how to fork a project on gitlab. You do this by clicking a 'fork' link in upper right part of the UI

我想你的意思是如何在 gitlab 上 fork 一个项目。您可以通过单击 UI 右上角的“分叉”链接来执行此操作

回答by VonC

GitLabintegration with Gitoliteis mainly at the project level, to register users to project (only if said users have registered a public ssh key, otherwise, they won't even appear in the gitolite.conffile)

GitLabGitolite 的集成主要是在项目层面,将用户注册到项目中(前提是该用户已经注册了公共 ssh 密钥,否则他们甚至不会出现在gitolite.conf文件中)

So for branch access, like personal branches, you need to have access to gitolite-admin project, clone that project and modify the gitolite.confyourself.

因此,对于分支访问,如个人分支,您需要访问 gitolite-admin 项目,克隆该项目并自行修改gitolite.conf

But even if you do, you won't see a graphical representation of that special Gitoite right in GitLab.
Even in its latest version (I am running a 3.2.0pre ff9a2e2, a commit from November 28th).

但即使你这样做了,你也不会在 GitLab 中看到那个特殊 Gtoite 的图形表示。
即使是最新版本(我运行的是 3.2.0pre ff9a2e2,11 月 28 日的提交)。



Personnal branches on Gitolite:

Gitolite 上的个人分支:

"personal" branches are great for environments where developers need to share work but can't directly pull from each other (usually due to either a networking or authentication related reason, both common in corporate setups).

Personal branches exist in a namespace of their own. The syntax is

“个人”分支非常适合开发人员需要共享工作但不能直接相互拉取的环境(通常是由于网络或身份验证相关的原因,这两者在公司设置中都很常见)。

个人分支存在于它们自己的命名空间中。语法是

RW+ personal/USER/  =   @userlist

where the "personal" can be anything you like (but cannot be empty), and the "/USER/" part is necessary (including both slashes).

A user "alice" (if she's in the userlist) can then push any branches inside personal/alice/. Which means she can push personal/alice/fooand personal/alice/bar, but NOT personal/alice.

其中 " personal" 可以是您喜欢的任何内容(但不能为空),而 " /USER/" 部分是必需的(包括两个斜杠)。

用户“ alice”(如果她在用户列表中)然后可以将任何分支推送到个人/alice/ 中。这意味着她可以推动personal/alice/foopersonal/alice/bar,但不能personal/alice



Where it gets complicated is that GitLab won't register 'alice' (named after your public key alice.pub.
When GitLab receives your public key, it will create a public key file (stored in the gitolite-admin/keydir) named (for instance)... alice_mail_com_123456789.pub.

变得复杂的地方是 GitLab 不会注册 ' alice' (以您的公钥命名alice.pub
当 GitLab 收到您的公钥时,它会创建一个公钥文件(存储在gitolite-admin/keydir),名为(例如)... alice_mail_com_123456789.pub

That is:

那是:

  • alice email
  • a timestamp (according to an edit by an "anonymous user": it is not, as I initially thought, a generated random id)
  • 爱丽丝邮箱
  • 时间戳(根据“匿名用户”的编辑:它不是,正如我最初认为的那样, 生成的随机 ID)

So you need, in your custom rules that you add to your gitolite.conf, to reuse that specific "GitLab" name.

因此,您需要在添加到 的自定义规则中gitolite.conf重复使用该特定的“GitLab”名称。

回答by VonC

Issue the following command in your terminal:

在终端中发出以下命令:

git branch yourbranchname

To check for how many branches available in our git project type:

要检查我们的 git 项目类型中有多少可用的分支:

git branch