The clone
command creates a new git repository, initialized from
a TFS source tree and fetch all the changesets
Usage: git-tfs clone [options] tfs-url-or-instance-name repository-path <git-repository-path>
-h, -H, --help
-V, --version
-d, --debug Show debug output about everything git-tfs does
-i, --tfs-remote, --remote, --id=VALUE
The remote ID of the TFS to interact with
default: default
--template=VALUE Passed to git-init
--shared[=VALUE] Passed to git-init
--autocrlf=VALUE Normalize line endings (default: false)
--ignorecase=VALUE Ignore case in file paths (default: system default)
--bare clone the TFS repository in a bare git repository
--workspace=VALUE set tfs workspace to a specific folder (a
shorter path is better!)
--ignore-regex=VALUE a regex of files to ignore
--no-metadata leave out the 'git-tfs-id:' tag in commit
messages
Use this when you're exporting from TFS and
don't need to put data back into TFS.
-u, --username=VALUE TFS username
-p, --password=VALUE TFS password
--all, --fetch-all
--parents
--authors=VALUE Path to an Authors file to map TFS users to Git users
--with-branches init all the TFS branches during the clone
To clone all of $/Project1
from your TFS 2010 server tfs
into a new directory Project1
, do this:
git tfs clone http://tfs:8080/tfs/DefaultCollection $/Project1
Sometimes, it could be interesting to clone only a branch of a TFS repository (for exemple to extract only the trunk of your project and manage branches with [branch](branch.md)
.
Suppose you have on TFS:
A <- B <- C <- D <- E $/Project1/Trunk
\
M <- N $/Project1/Branch
Then, do this (the clone will be done in the MyProject1Directory
directory):
git tfs clone http://tfs:8080/tfs/DefaultCollection $/Project1/Trunk MyProject1Directory
Note : It is highly recommanded to clone the root branch ( the branch that has no parents, here
If you don't know exactly what repository path to clone, see list-remote-branches command to get a list of the existing repositories.
If you want to clone your entire repository with all the branches or that the tfs branches are merged througth merge changeset, perhaps you should use the option --with-branches
:
git tfs clone http://tfs:8080/tfs/DefaultCollection $/Project1/Trunk --with-branches
All the tfs history (and all the branches) and the merge changesets will consequently be fetched from TFS and created in the git repository!
Let's say you want to clone $/Project
, but you don't want to
clone exes.
git tfs clone --ignore-regex=exe$ http://tfs:8080/tfs/DefaultCollection $/Project1
If the TFS server need an authentication, you could use the --username and --password parameters. If you don't specify theses informations, you will be prompted to enter them. If you use these parameters, the informations, git-tfs will store these informations (in the .git/config file --in clear--) and never prompt you again. If you don't want your password to be saved, don't use these options.
git tfs clone http://tfs:8080/tfs/DefaultCollection $/Project1 -u=DISSRVTFS03\peter.pan -p=wendy
With the parameter --authors, you could specify a file containing all the mapping of the TFS users to the git users. Each line describing a mapping following the syntax:
DISSRVTFS03\peter.pan = Peter Pan <[email protected]>
The clone command will be :
git tfs clone http://tfs:8080/tfs/DefaultCollection $/Project1 --authors="c:\project_file\authors.txt"
Once the clone is done, the file is store in the .git
folder (with the name git-tfs_authors) and used with later fetch
. You could overwrite it by specifting another file (or go delete it).
By default, git-tfs use as a Tfs workspace an internal directory and you shouldn't care about ;) But, due to file system limitations, it could be usefull to set a custom directory (with a path as short as possible) as a tfs wordspace. You could do it with the --workspace parameter:
git tfs clone http://tfs:8080/tfs/DefaultCollection $/Project1 --workspace="c:\ws"
It is recommended, especially if the TFS repository is a big one, to run, after a clone :
- a git garbage collect :
git gc
- a cleanup :
git tfs cleanup