Search code examples
gitversion-controlbranching-and-mergingfeature-branch

Create a branch alias?


I am researching switching from starteam to Git.

Currently, in starteam, we use "floating views" with special names. These floating views basically work like aliases. Therefore, we can specify a specific alias to checkout from and we'll get the branch that we're currently model testing.

How would this be done in Git? This is basically how our branches are organized:

These are all branches

master (stable view)
   |  - Branch 2012.05.01
   |          | - Project 1
   |          | - Project 2
   |          | - model [floating view / alias to Branch 2012.05.01]
   |
   |  - Branch 2012.07.11   (these would also have various child views for projects)
   |  - Branch 2012.10.17

(Branch 2012.05.01 would be merged to master when model testing is complete.)

In our automated scripts (ant), to run our model deployment, we just checkout from our branch called model. This way we never have to change our scripts as we change which branch we are model testing, and finding out which view we're model testing is as easy as figuring out which branch the model branch references.

Is there any such way to do something similar in Git?

To clarify:

  1. I want an alias of a branch. A branch, not a commit.
  2. Branch 2012.05.01 means the branch intended to be shipped on 2012.05.01, it doesn't mean a 2012.05.01 moment in time.
  3. I want an alias to Branch 2012.05.01. Branch 2012.05.01 is an integration branch, it's constantly modified. But I don't want to reference it as Branch 2012.05.01, I want to reference it as model. This way, I can change my the alias to Branch 2012.07.11 and it will get the most recent code from that branch without changing any of the checkout code script.

Solution

  • Please see here: https://stackoverflow.com/a/549949/606723

    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
    

    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.).