The Clone command clones from a StarTeam view into a newly created directory, creates remote-tracking branches for each child view (branch) in the cloned repository (visible using git branch -r ), creates and checks out an initial branch that is forked from the main StarTeam view.
The first user who clones from a StarTeam view establishes a clone time and checks out all files from the view based on the clone time. The first Clone operation does not fetch any history prior to the 'clone time' into the git repository. Also existing child views will not be fetched as branches.
Future Clone operations however, will fetch history from the StarTeam view since the 'clone time' also creates branches in Git corresponding to child views created since the 'clone time'.
After the Clone, a plain git fetch without arguments will update all the remote-tracking branches, and a git pull without arguments will in addition merge the remote master branch into the current master branch, if any. All StarTeam change packages created since the last pull/fetch will be fetched as a Git commit.
The following is the syntax for StarTeam connection url string: (Entries within [] are optional)
starteam://[username:password@]<hostname>:<port>/<project name>[/<view name>][/<folder path>]
This example shows you how to clone to a new Git repository where:
C:\gitdemo\Sample> git clone Administrator:Administrator@10.150.1.12:49201/SampleProject/SampleView
The above command clones a new Git repository in the current working folder and checks out the files from 'SampleView' to disk. Note that the username/password can be optionally passed in the command line. Recommended way is to use the Git credential manager to store the credentials on Windows.
The following is an example for specifying a full view hierarchy.
C:\gitdemo\Sample>git clone "10.150.1.12:49201/SampleProject/SampleView:1.x Release:1.2 Release"
C:\gitdemo\Sample>git clone "10.150.1.12:49201/SampleProject/SampleView/src/core/java”
While cloning from a sub folder, branches are not cloned. The clone command is performed on the view configuration as of current time and not of the 'clone time'.
C:\gitdemo\Sample>git clone "10.150.1.12:49201/SampleProject”
When a shortened form of URL without a view name in it is passed, the clone command clones from the root (default) view of the project.
When a user clones from a StarTeam view, child views of the main view created after the established 'clone time' are cloned as branches in Git repository. Note that only accessible derived views of Branch-all Variant view type are supported to be cloned as branches. Other types of views like Reference views, Non-derived views and Branch-none variant views are not considered for branching.
Let's take an example of a StarTeam View hierarchy
Demo
Assuming that the child views (1.0, 2.0, 3.0, Sandbox) were created after the 'clone time', the following command clones the main view of the Demo project along with its child views
C:\gitdemo\Sample>git clone "localhost:49201/Demo/Demo”
A dialog box is shown where the user can select the branches to be cloned along with the main view. All immediate child views are available by default for branching.
Any child views excluded by the user would mean that subsequent pulls/push commands would ignore that view too.
The above clone command would fetch all the child views as branches and checkout from the master branch (view). The branches be verified using the following git branch command.
C:\gitdemo\Sample > git branch -a
* master remotes/origin/1.0_Release remotes/origin/HEAD -> origin/master remotes/origin/2.0_Release remotes/origin/3.0_Release remotes/origin/Sandbox remotes/origin/master
As the command output shows, clone command successfully created remote tracking branches for each valid child view.
To checkout to a specific branch, run the following command:
C:\gitdemo\Sample > git checkout 2.0_Release
The checked out content should map exactly with the '2.0 Release' view in StarTeam.
Note the difference between the child view names in StarTeam and the Git branch ref name. In Git ref names for branches follow certain naming conventions . It is important that StarTeam view names are normalized accordingly. All special characters in the StarTeam view names are replaced by hyphens ('-') and blanks are replaced by underscores ('_'). Leading and trailing slashes, dots, hyphens, and underscores are also removed.
If the user is running in a command line mode and wants to disable the branch selection pop-up dialog , the Git clone command should be run with a configuration option (git-st.server.noprompt) set as follows:
C:\gitdemo\Sample>git clone "starteam://localhost:49201/Demo” -c “git-st.server.noprompt=true”
The above command would check out all valid views as branches by default to the Git repository.
To check out just the master branch use the –single-branch option:
C:\gitdemo\Sample>git clone "starteam://localhost:49201/Demo” -c “gitst. server.noprompt=true” –single-branch
To exclude certain branches during clone use the git config option excludeBranches as show below:
C:\gitdemo\Sample>git clone "starteam://localhost:49201/Demo” -c “gitst. server.noprompt=true” --config "git-st.server.excludedBranches=1.0,2.0"
The above command would exclude branches 1.0,2.0 from
The following are some of the supported Git clone options with the StarTeam Git Client: