git – 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.
- Android studio and git
- Mercurial “no username supplied” error on Mac
- Version control for large php/mysql web application
- Git stash then checkout each time
- restore deleted git branch you don't know the name of
- Mantaining a CMS and websites with Mercurial
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?
Edit: people are getting confused here.
- I want an alias of a branch. A branch, not a commit.
- “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
- I want a 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.
3 Solutions collect form web for “git – branch alias?”
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,
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.
In case when you need branch per feature — answer of Adam Dymitruk is correct,
But in case when you need save links branch – specific state (based on time), without changed them you can use git tags.
I used tags for store states of each prod releases.