Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create a branch alias? [duplicate]

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.
like image 689
user606723 Avatar asked Jan 16 '13 19:01

user606723


2 Answers

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

like image 182
user606723 Avatar answered Sep 22 '22 15:09

user606723


Git does not support aliases for branches.

This means you will have to rely on variables in your script to make model="branch.2012.10.17" or something like that. Your script would do something like this then:

git checkout $model 

I'm leaving the rest of this answer here for where we came from in this discussion:

A very involved discussion on branching strategy can be found here: http://dymitruk.com/blog/2012/02/05/branch-per-feature/

Specifically, take a look at the role of the integration branch and the release candidate branch. This may be what you are looking for.

Look at git as something that takes a snapshot of your working directory, not as histories of folders.

progit.org/book explains the Directed Acyclic Graph that stores the history. All references are just things that point to nodes in it. That should clarify how you want to construct your workflow.

make a start tag - version2.1. from there make your int-version2.1 (using nubmers instead of dates for brevity). Any work you start, start from the version 2.1 tag. merge the work into the int-version2.1. Others will do the same.

like image 42
Adam Dymitruk Avatar answered Sep 24 '22 15:09

Adam Dymitruk