Merge pull request #446 from pmiossec/doc

Doc
This commit is contained in:
Sean M. Collins
2013-09-25 12:23:33 -07:00
12 changed files with 445 additions and 3 deletions
+3
View File
@@ -14,6 +14,9 @@ If you see something easy to change, you can probably even make the change in yo
3. **Ask questions.** Feel free to drop me a line, or ask a question over at the [google group](http://groups.google.com/group/git-tfs-dev/), or join `#git-tfs` on FreeNode.
4. Verify that you your editor is configured to use 4 spaces instead of tabs. You could even install the [EditorConfig Extension for VisualStudio](http://visualstudiogallery.msdn.microsoft.com/c8bccfe2-650c-4b42-bc5c-845e21f96328) (such plugin exists for other editors) , and the good space configuration will be set automatically when opening the git-tfs solution.
## Pull Requests
Here are some tips on creating a pull request:
+1
View File
@@ -13,6 +13,7 @@ namespace Sep.Git.Tfs.Commands
{
[Pluggable("branch")]
[Description("branch\n\n" +
" * Display inited remote TFS branches:\n git tfs branch\n\n" +
" * Display remote TFS branches:\n git tfs branch -r\n git tfs branch -r -all\n\n" +
" * Create a TFS branch from current commit:\n git tfs branch $/Repository/ProjectBranchToCreate <myWishedRemoteName> --comment=\"Creation of my branch\"\n\n" +
" * Rename a remote branch:\n git tfs branch --move oldTfsRemoteName newTfsRemoteName\n\n" +
+2 -1
View File
@@ -72,7 +72,8 @@ You need .NET 4 and either the 2008, 2010 or 2012 version of Team Explorer insta
# or shelve your changes :
git tfs shelve MY_AWESOME_CHANGES
You could find more interesting [uses cases](doc/usecases/usecases.md) on how to use git-tfs.
git-tfs is designed to work outside of any existing TFS workspaces.
## Available commands / options
+35
View File
@@ -0,0 +1,35 @@
Sometimes, depending on where is located your repository folder on your drive and what is the file arborescence of your project,
you could face errors because you exceed the 259 characters limit of NTFS file system.
These errors could be :
`TF205022: The following path contains more than the allowed 259 characters:C:/Very/Long/Path/.git/tfs/default/workspace/Very/Long/Path/To/SubFolder/file.txt. Specify a shorter path.`
or
`Failed to stat file 'C:/Very/Long/Path/.git/tfs/default/workspace/Very/Long/Path/To/SubFolder/file.txt': The system cannot find the file specified.`
This is due to the fact that git-tfs use a temp folder located in the folder `.git/tfs/default/workspace` (`default` is use for the main branch but, if you use TFS branch feature of git-tfs, other --longer?-- folders following the branch name are used) where it create files received from TFS to create the git commits. The path of the files could became quickly very long...
Note: If you look for this folder, you surely couldn't find it because it is created and deleted when a git-tfs command is run!
A first simple solution could be to move your folder from a very long path to a shorter one.
For exemple, move your repository folder from :
`C:\A\Very\Very\Long\Path\To\My\GitTfs\Repository` to `C:\repo`.
Another better solution if you faced this problem is to use a custom workspace directory!
To set a custom workspace directory, just run the command (in a already existing repository):
`git config git-tfs.workspace-dir c:\ws`
Note: if you set this setting after having faced an error perhaps you should run a cleanup before fetching again ( `git tfs cleanup` )
But it is possible that you faced the problem when you try to clone a big repository and, thus, you could not run the previous command because the repository is not yet created :(
So, in this case, you should just init the repository, set the custom workspace directory, then fetch the tfs changesets :
git tfs init http://server/tfs $/Project/trunk project
cd project
git config git-tfs.workspace-dir c:\ws
git tfs pull
More informations : See [here](https://github.com/git-tfs/git-tfs/issues/314) or [there](https://github.com/git-tfs/git-tfs/issues/430) or [there](https://github.com/git-tfs/git-tfs/pull/266)
+1
View File
@@ -2,3 +2,4 @@ Here are some common git-tfs problems.
* [Checkin policy doesn't work](troubleshooting-checkin-policies.md)
* [TF400813 error with visualstudio.com](TF400813-error-with-visualstudio.com.md)
* [Set custom workspace to bypass errors due to NTFS length path limits of 259 characters](Set-custom-workspace.md)
+7
View File
@@ -33,9 +33,16 @@ into a new directory `Project1`, do this:
git tfs init http://tfs:8080/tfs/DefaultCollection $/Project1
then, to retrieve tfs changesets do this :
git tfs pull
Note: [pull] is here prefered to [fetch], otherwise the git branch `master` won't be created :(
## See also
* [clone](clone.md)
* [quick-clone](quick-clone.md)
* [pull](pull.md)
* [fetch](fetch.md)
* [Set custom workspace to bypass errors due to NTFS length path limits of 259 characters](../Set-custom-workspace.md)
+203
View File
@@ -0,0 +1,203 @@
Git-tfs could be easily used to work with TFS branches.
# Cloning
## Find the tfs branch to clone (optional)
Note: This command is not supported in TFS2008
If you don't know (or remember) the path of the project you want to clone on a TFS server,
you could use the `list-remote-branches` command :
git tfs list-remote-branches http://tfs:8080/tfs/DefaultCollection
You will have an output like that (showing branch linked to its parent branch) :
$/project/trunk [*]
|
+- $/project/branch1
|
+- $/project/branch2
|
+- $/project/branch3
| |
| +- $/project/branche3-1
|
+- $/project/git_central_repo
$/other_project/trunk [*]
|
+- $/other_project/b1
|
+- $/other_project/b2
Cloning root branches (marked by [*]) is recommended!
PS:if your branch is not listed here, perhaps you should convert the containing folder to a branch in TFS.
If you want to work with tfs branches, you should clone one of the root branches (marked by [*]) :
`$/project/trunk` or `$/other_project/trunk`
## Clone just the trunk
You could clone only the trunk of your project (and init the other branches later).
For that, use the command:
git tfs clone http://tfs:8080/tfs/DefaultCollection $/project/trunk .
See [clone](../commands/clone.md) command if you should use a password or an author file, ...
Wait quite some time, fetching changesets from TFS is a slow process :(
Pros:
- quicker than cloning all the history
- get a smaller repository
- This command is supported in TFS2008
Cons:
- don't have all the whole history in the git repository (and that's the goal of a dvcs)
- ignore merges between branches! A branch merged in another one won't be materialized in the git repository and will never be.
__If you have merges, don't use this method!!__ If a merge is detected during the fetch, warning message will be displayed.
It is higly recommended to use the other method if you see one.
## Clone All History
First fetch all the source history (with all branches) in a local git repository:
git tfs clone http://tfs:8080/tfs/DefaultCollection $/project/trunk . --with-branches
Wait quite some time, fetching all the changesets from TFS is even longer :(
Pros:
- you have all the whole history in the git repository
- manage merges between branches! A branch merged in another one will be materialized in the git repository.
Cons:
- slower than cloning just the main branch
- get a bigger repository
- This command is not supported in TFS2008
# Working with the trunk
Working with the trunk is like working without branches.
See [Working with no branches](working_with_no_branches.md) for more details.
# Working with branches
## Fetch, Pull and Check in
Working with branches, for the main commands (`fetch`, `pull` and `rcheckin`), is similar than for the trunk
but with specifying the tfs remote with the option `-i`.
//fetch the new changesets
git tfs fetch -i branch1
//fetch and rebase on new changesets
git tfs pull -r -i branch1
//Check in TFS
git tfs rcheckin -i branch1
All the others actions are done throught the `branch` command
## List branches
### Display already initialized Tfs remote
You will have the list of the already initialized Tfs branches and also the last changeset fetched.
git tfs branch
### Display existing Tfs remote in current Tfs project
git tfs branch -r
### Display existing Tfs remote in all the Tfs projects
git tfs branch -r -all
# Initialize an existing remote TFS branch
## Initialize one tfs branch
git tfs branch --init $/Repository/ProjectBranch
## Initialize one tfs branch (with TFS2008)
With TFS2008, git-tfs is unable to find the parent branch of the branch we want to initialize.
It's a needed informations to find the root changeset. To tell git-tfs, we must use the `--tfs-parent-branch` option:
git tfs branch --init --tfs-parent-branch=$/Repository/ProjectParentBranch $/Repository/ProjectBranch
## Initialize one tfs branch, setting its name
git tfs branch --init $/Repository/ProjectBranch myNewBranch
## Initialize all the tfs branches
git tfs branch --init --all
## Create a TFS branch
### Create a TFS branch from scratch
You have first to checkout a commit corresponding to a tfs changeset already check in.
Once done, you just have to create a branch with the command:
git tfs branch $/Repository/ProjectBranchToCreate --comment="Creation of my branch"
Git-tfs will create a branch on TFS with the path "$/Repository/ProjectBranchToCreate" where the first
changeset comment will be "Creation of my branch". The name of the tfs remote will be extracted from the Tfs path
and will be "ProjectBranchToCreate".
If you want to use a different name for your tfs remote, just specify it:
git tfs branch $/Repository/ProjectBranchToCreate myNewProject --comment="Creation of my branch"
### Create a TFS branch from an existing git branch
Sometime, it's easier to create a local git branch, work in it and later decide to create a TFS branch.
When you are ready to check in your work in tfs, just checkout your local branch then use the command:
git tfs branch $/Repository/ProjectBranchToCreate --comment="Creation of my branch"
The tfs branch will be created and all the git commits in the local branch will be checked in the Tfs branch \o/
## Rename a remote branch
This command will only rename the local remote and will not rename the branch in TFS.
git tfs branch --move oldTfsRemoteName newTfsRemoteName
## Delete a remote branch
This command will only delete the local remote and will not delete the branch in TFS.
git tfs branch --delete tfsRemoteName
## Manage merges with git-tfs
Git-tfs can handle merges (ie merge changesets) but there is some restrictions and you must follow some rules to do it well
### Fetch an existing merge changeset
If git-tfs encounter a merge changeset when fetching changesets, there is 2 possibilities:
* Either, the 2 parent changesets have already been fetched and a merge commit will be created localy (the merge changeset has been well managed).
* Either, the parent of the merged branch has not already been fetch. Then the merge changeset will be ignored and a nomal commit will be created
(the merge changeset has not been well managed). In this case, a warning will be displayed.
You should know that if you don't manage well merge changesets and that, in the future, you want to merge again the 2 branches, you will issue a lot of merge conflicts!
You could prevent that by doing 2 things:
* cloning using the `--with-branches` option which will manage well all the merge changesets
* always fetch the merge branch before fetching a merge changeset
Note: if you see a warning, you could correct that by reseting the tfs remote to a previous commit. Then fetch the merged branch and retry to fetch the branch.
### Merge 2 branches and checkin this merge in Tfs
Because merging 2 branches with git is a lot more easy than with Tfs, you could use git-tfs to do it.
If you want, for exemple, to merge the branch `b1` in the trunk `trunk`, you need that `b1` and `trunk` to be entirely checked in Tfs.
Once done, you could do the merge with git as a normal merge with 2 local git branches.
Then you have to check this commit into Tfs with the command `rcheckin` and a merge changeset will be created into Tfs.
+40
View File
@@ -0,0 +1,40 @@
Git-tfs could be easily used to migrate source history from TFSVC to a git repository.
### Fetch All History
First fetch all the source history (with all branches) in a local git repository:
git tfs clone https://tfs.codeplex.com:443/tfs/Collection $/project/trunk . --with-branches
See [clone](../commands/clone.md) command if you should use a password or an author file
(recommended if you want an mail adresse instead of a windows login in commit messages), ...
Wait quite some time, fetching changesets from TFS is a slow process :(
### Clean commits (optional)
Clean all the git-tfs metadatas from the commit messages:
git filter-branch -f --msg-filter 'sed "s/^git-tfs-id:.*$//g"' -- --all
Then verify that all is ok and delete the folder `.git/refs/original` ( to delete old branches)
Note: if you do that, you won't be able to fetch tfs changesets anymore.
You should do that if you want to migrate definitively away of TFS!
### Add a remote toward git central repository
Add a remote in your local repository toward an empty git (bare) central repository :
git remote add origin https://github.com/user/project.git
### Push all the source history
Push all the branches on your remote repository:
git push --all origin
Migration is done!
+6
View File
@@ -0,0 +1,6 @@
#Use cases
* [Working with no branches](working_with_no_branches.md)
* [Manage TFS branches with git-tfs](manage_tfs_branches.md)
* [Migrate your history from TFSVC to a git repository](migrate_tfs_to_git.md)
* [Working with shelvesets](working_with_shelvesets.md)
+86
View File
@@ -0,0 +1,86 @@
Git-tfs could be easily used to work with TFS.
# Cloning
## Find the tfs branch to clone (optional)
Note: This command is not supported in TFS2008
If you don't know (or remember) the path of the project you want to clone on a TFS server,
you could use the `list-remote-branches` command :
git tfs list-remote-branches http://tfs:8080/tfs/DefaultCollection
You will have an output like that (showing branch linked to its parent branch) :
$/project/trunk [*]
|
+- $/project/branch1
|
+- $/project/branch2
|
+- $/project/branch3
| |
| +- $/project/branche3-1
|
+- $/project/git_central_repo
$/other_project/trunk [*]
|
+- $/other_project/b1
|
+- $/other_project/b2
Cloning root branches (marked by [*]) is recommended!
PS:if your branch is not listed here, perhaps you should convert the containing folder to a branch in TFS.
If you want to work with tfs branches, you should clone one of the root branches (marked by [*]) :
`$/project/trunk` or `$/other_project/trunk`
## Clone just the trunk
You could clone only the trunk of your project (and init the other branches later).
For that, use the command:
git tfs clone http://tfs:8080/tfs/DefaultCollection $/project/trunk .
See [clone](../commands/clone.md) command if you should use a password or an author file, ...
Wait quite some time, fetching changesets from TFS is a slow process :(
Pros & Cons: See [Manage Tfs branches](manage_tfs_branches.md).
# Working with the trunk
## Fetch Tfs changesets
To fetch the new changesets, just do:
git tfs fetch
but be aware that this command DON'T include the new changesets in your git branch (like the git fetch).
To do so, you have to use the `merge` or `rebase` git command or prefer the git-tfs `pull` command.
## Merge or Rebase fetched Tfs changesets
### Rebase
If you want to rebase all your local commits onto the newly fetch changesets, use the command:
git tfs pull -r
### Merge
You could also merge your commits into the ones fetch with the command:
git tfs pull
but this solution is discouraged because merged commits couldn't be push to tfs as this and you will finish with strange git history!
## Check in TFS
Once you've rebased your commits onto the newly fetched changesets, you could check them in TFS:
git tfs rcheckin
+61
View File
@@ -0,0 +1,61 @@
With git-tfs, you could manage TFS shelvesets.
If you began to use git-tfs to move away of TFS, perhaps you want to import into git some existing shelvesets.
Let's see how to do it!
# Listing existing shelvesets
The first thing to do to use an existing shelveset is to find it among your shelvesets or the ones of the other users.
To do that, you should them with the `shelve-list` command.
## List your shelvesets.
If you want to list your shelvesets, just do:
git tfs shelve-list
The output of this command looks like that:
SND\vtccds_cp feature, find the good client
SND\vtccds_cp better solution
For each changeset, you've first the user login and then, what we need, the name of the shelveset!
Note :
* use the `--full` option to get more informations
* Shelvesets are sorted by date by default
## List the shelvesets of all the TFS users.
If you want to include in the list the shelvesets of all the users, just do:
git tfs shelve-list -u=all
# Unshelve a shelveset
Once you've found the name of the shelveset, you could use the `unshelve` command to fetch the shleveset in your repository.
## Unshelve one of your shelveset
When you want to unshelve a shelveset, the changeset defined by the shelveset is automatically created in a new branch.
You only have to specify the name of the shelveset and the name of the branch that will be created.
git tfs unshelve "better solution" MyShelvesetBranch
Note: - the branch is automatically created on the parent commit of the changeset
## Unshelve a shelveset of another user
To do that, you should specify the login of the user in addition to the shelveset name:
git tfs unshelve -u=loginUser "paul solution" MyBranch
# Create a shelveset
Perhaps, for a reason of another, you should want to create a shelveset to exchange code with user still using TFS ( :( for them )
A shelveset is created with the changes of the commits done in the current branch since the last commit fetch from TFS.
To create the shelveset, just do:
git tfs shelve "try to solve bug234"
-2
View File
@@ -8,12 +8,10 @@ Here are some things I'd like to do with git-tfs:
* Use a newer build of henon/gitsharp to fix [the out of memory problem](https://github.com/git-tfs/git-tfs/issues/22).
* Use [libgit2/libgit2sharp](https://github.com/libgit2/libgit2sharp) for more git operations
* Clean up the object model.
* Translate TFS branches into git branches.
* Translate TFS labels into git tags.
* Faster import (clone and/or quick-clone) ([in progress](https://github.com/git-tfs/git-tfs/issues/173))
* git-fast-import?
* TFS get specific version, then add?
* Config params to support a more concise notation for TFS server URLs and/or a default server URL.
* A more nuanced fetch spec, similar to working directory specs from TFS.
* Work in bare repositories.
* make tfs a "real" remote with git-remote-&lt;vcs&gt; ?