You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何先配置Git仓库再通过git-tfs导入TFS提交至Git?

Absolutely feasible—this is actually the optimal approach to avoid post-import LFS migrations! Setting up your Git LFS configuration upfront ensures large files are tracked correctly from the moment you pull in TFS changesets. Let me walk you through the exact steps to make this work smoothly:

Step 1: Initialize Git Repository & Configure LFS
  • Create a new empty folder for your Git repo, then navigate into it via your terminal/command prompt.
  • Run git init to initialize the blank Git repository.
  • Install Git LFS locally (this sets up the necessary hooks):
    git lfs install
    
  • Define which file types you want LFS to track (in your case, .bin files):
    git lfs track "*.bin"
    
    This automatically creates/updates a .gitattributes file with the appropriate LFS rules.
  • Verify the .gitattributes file is correct—open it and confirm it contains a line like:
    *.bin filter=lfs diff=lfs merge=lfs -text
    
  • Commit this initial configuration to lock in your LFS setup:
    git add .gitattributes
    git commit -m "Initialize repo with LFS tracking for *.bin files"
    
Step 2: Set Up git-tfs & Import TFS History
  • First, ensure git-tfs is installed (use your package manager or download it from official sources if you haven’t already).
  • Set the MSYS_NO_PATHCONV environment variable to prevent path conversion issues (critical for Windows/TFS paths):
    # For bash/zsh terminals
    export MSYS_NO_PATHCONV=1
    
    # For PowerShell
    $env:MSYS_NO_PATHCONV=1
    
  • Initialize git-tfs to connect to your TFS repository. Replace the placeholders with your actual TFS collection URL and branch path:
    git tfs init http://tfs:1234/tfs/YourCollectionName $/YourProjectName/PathToYourBranch
    
  • Import all TFS changesets into your Git repo:
    # Fetch all TFS changesets first
    git tfs fetch
    # Check out the fetched changes to merge them into your current Git branch
    git tfs checkout
    
    Git-tfs will convert each TFS changeset into a Git commit, and since your LFS configuration is already in place, any .bin files will be automatically handled by LFS during this process.
Step 3: Validate the Import
  • Confirm large files are tracked by LFS with:
    git lfs ls-files
    
    You should see all your .bin files listed here.
  • Check the commit history with git log to ensure all TFS changesets are preserved as Git commits.
  • Test cloning the repo to another location to make sure LFS files pull correctly (run git lfs pull if needed after cloning).
Critical Tips to Avoid Headaches
  • Never skip committing the .gitattributes before importing: git-tfs uses your repo’s current configuration during the import, so having LFS set up first guarantees large files are captured by LFS from the start.
  • If you need to track additional file types (e.g., .zip, .iso), add them with git lfs track "*.zip" before committing the .gitattributes.
  • For large TFS repos, speed up the import by processing changesets in batches:
    git tfs fetch --batch-size=50
    

内容的提问来源于stack exchange,提问作者sharpener

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 09:06:47