Creating aliases for Git branch names

孤人 提交于 2021-02-07 07:36:34

问题


Suppose I have the following branches in git:

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

I would like to easily switch between those to, like this:

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)

How can I do that in Git?


回答1:


You can try using git symbolic-ref (as mentioned in "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

You can find a similar example in this gist.



来源:https://stackoverflow.com/questions/26944235/creating-aliases-for-git-branch-names

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!