中为分支设置别名

中为分支设置别名

本文介绍了是否可以在 Git 中为分支设置别名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在考虑大规模使用 Git.我希望通过调用 master 分支 trunk 来提高采用率并使事情变得更容易.

I am looking into using Git on a massive scale. I was hoping to increase adoption and make things easier by calling the master branch trunk.

这可以并且将会给 SVN 用户一些舒适感.我知道我可以创建一个名为 trunk 的分支,但这似乎偏离了 Git 规范,可能会导致一些用户感到困惑.

This can and will give SVN users some feelings of comfort. I know I can create a branch called trunk, but that seems to deviate from the Git norms and might cause some users to get confused.

我知道我也可以创建和删除我内心深处的标签,但是当我检查这些标签时,它告诉我这是一个非本地分支,这对我来说很好,但可能不是我想要做的.

I know that I can also create and delete tags to my heart's content but when I checkout those tags it tells me it is a non local branch which is just fine with me but probably not what I want to be doing.

我是一个彻头彻尾的 Git 新手,但在发布和构建系统方面经验丰富.

I am a total Git newb but a seasoned professional at release and build systems.

我想要做的是能够调用主干.我已经看到了别名命令的能力——这是否也适用于版本化对象的名称?

What I want to do is to be able to call master trunk. I have seen the ability to alias commands – does this apply for the names of versioned objects as well?

我知道存在 git-svn 和其他工具,但分层存储库系统的开销让我感到害怕.

I know git-svn exists and other tools but the overhead of layered repository systems frightens me.

推荐答案

您可以按照 Greg 的建议重命名 master 分支主干,或者您也可以创建一个主干作为主分支的符号引用,以便 git 和svn 用户拥有他们习惯的主"分支.

You can rename the master branch trunk as Greg has suggested, or you can also create a trunk that is a symbolic reference to the master branch so that both git and svn users have the 'main' branch that they are used to.

git symbolic-ref refs/heads/trunk refs/heads/master

请注意,trunk 不是一等公民.如果您签出 trunk 并执行 git status 您实际上将在 master 上,但是您可以使用 trunk命令在您使用分支名称的所有地方(日志、合并等).

Note that trunk isn't a first class citizen. If you checkout trunk and perform a git status you will actually be on master, however you can use the trunk command in all places that you use the branch name (log, merge, etc.).

这篇关于是否可以在 Git 中为分支设置别名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 05:27