如何在TFS存储库中使用git-tfs和惯用的git分支? [英] How do I use git-tfs and idiomatic git branching against a TFS repository?
问题描述
我如何按照习惯使用git-tfs?
-
git的用法是检查分支到根目录存储库。检出一个分支将用该分支的内容替换该目录的内容。
TFS的习惯用法是检查不同的目录在存储库的根目录下(即使是主分支或中继分支)。检出一个分支会将它放到当前旁边的一个新目录中。 使用 git-tfs ,我可以克隆一个TFS仓库或分支到一个git仓库。我想以与git分支成语一致的方式在具有多个分支的TFS存储库上工作。但我不确定技术上可行或推荐的):
克隆整个TFS信息库
如果我从TFS克隆整个存储库
> git tfs clone http://< tfsurl>:8080 $ / main
这会给我一个git master
包含 all TFS分支作为目录。
[主] GT; dir
trunk
功能登录
功能搜索
发布-0.0
为每个TFS分行添加一个远程分支
我不知道我是否可以(或如何)映射一个git远程到每个TFS分支。
> git init。
[master]> git tfs clone http://< url> $ / main / trunk。
然后
[主] GT; git checkout -b功能登录
[功能登录]> git tfs clone http://< url> $ / main / feature-logon。
我知道这在技术上是不正确的,但我不知道没有更好的玩法(我唯一的TFS回购是非常大的,实验需要很长时间)
现在可以得到TFS分支是正确的Git分支如果使用 git-tfs 进行克隆。这是现在在稳定版本!您首先克隆整个存储库,但不包括干线:
git tfs克隆http://< tfsurl>:8080 $ / main / trunk
然后运行 branch --init
,它在Git仓库中创建一个新的分支
git tfs branch --init $ / MyProject / MyTFSBranch
在您的情况下:
git tfs branch --init $ / main / feature-logon
或者使用 - 全部
标记在新克隆的存储库上,以创建TFS服务器上的所有分支。
git tfs branch --init --all
您也可以直接克隆与所有分支使用标志 - 与分行
:
git tfs clone http://< tfsurl>:8080 $ / main / trunk --with-branches
这个新命令的文档是这里。随时提供反馈,以改善它...
How Do I Use git-tfs Idiomatically?
The git idiom is to check out branches to the root directory of the repository. Checking out a branch will replace the contents of the directory with the contents of that branch.
The TFS idiom is to check out each branch in a different directory under the root directory of the repository (even the master or trunk branch). Checking out a branch will place it in a new directory next to the current one.
Using git-tfs, I can clone a TFS repository or branch into a git repository. I want to work on a TFS repository with multiple branches in a manner consistent with the git branching idiom. But I'm not sure what's technically possible or recommended :)
Clone The Whole TFS Repository
If I clone the whole repository out of TFS
> git tfs clone http://<tfsurl>:8080 $/main
That would give me a git master
containing all the TFS branches as directories.
[master]> dir
trunk
feature-logon
feature-search
release-0.0.1
Add a Remote Per TFS Branch
I don't know if I can (or how to) map a git remote to each TFS branch.
> git init .
[master]> git tfs clone http://<url> $/main/trunk .
Then
[master]> git checkout -b feature-logon
[feature-logon]> git tfs clone http://<url> $/main/feature-logon .
I know this is technically incorrect, but I don't know any better without playing (my only TFS repo is very large, experimenting is taking a long time)
It's now possible to get the TFS branches to be correct Git branches if cloning using git-tfs. This is now in the stable release! You first clone not the entire repository but the trunk :
git tfs clone http://<tfsurl>:8080 $/main/trunk
Then you run branch --init
, which creates a new branch in the Git repository
git tfs branch --init $/MyProject/MyTFSBranch
in your case :
git tfs branch --init $/main/feature-logon
Or use the the --all
flag on a fresh cloned repository to create ALL the branches present on the TFS server.
git tfs branch --init --all
You could also clone directly with all the branches using flag --with-branches
:
git tfs clone http://<tfsurl>:8080 $/main/trunk --with-branches
The documentation for this new command is here. Feel free to provide feedback to improve it...
这篇关于如何在TFS存储库中使用git-tfs和惯用的git分支?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!