为Git分支名称创建别名

时间:2014-11-15 08:58:30

标签: git branch alias git-checkout

假设我在git中有以下分支:

  • master
  • release-2014-11-02-some-long-text

我想在这些之间轻松切换,如下:

git checkout devel # checkout to master
git checkout release # checkout to the branch release currently points/aliases to, in this case:  release-2014-11-02-some-long-text (I would like to change this alias from time to time)

我怎么能在Git中做到这一点?

1 个答案:

答案 0 :(得分:7)

您可以尝试使用git symbolic-ref(如“Is it possible to alias a branch in Git?”中所述):

git symbolic-ref refs/heads/devel   refs/heads/master
git symbolic-ref refs/heads/release refs/heads/release-2014-11-02-some-long-text

您可以找到similar example in this gist