2015-10-20 75 views
0

我在Visual Studio中使用TFS和Git,我希望能夠導出或克隆所有未決文件和文件結構到我選擇的文件夾,以便我的待處理的更改可以在本地進行備份,而不是擱置或暫存待定文件。我目前不得不在Windows資源管理器中打開每個文件,然後運行腳本將文件及其文件結構複製到我的備份位置,這非常耗時且易於發生手動錯誤。有誰知道TFS中的插件,功能,任何Git工具或Visual Studio中的哪些工具可以將未決文件及其文件結構複製到我選擇的文件夾中?克隆文件結構的Visual Studio中掛起的更改

回答

0

你可以使用TFS API來實現你想要的。獲取所有文件,文件夾並獲取他們的目錄。判斷文件是否正在等待更改。然後使用您的腳本將文件複製到備份位置。

工作區,你的代碼中引用:

private void PopulateTreeView(string workspaceName) 
{ 
    // Connect to TFS - VersionControlServer Service 
    var tfs = 
     TfsTeamProjectCollectionFactory.GetTeamProjectCollection 
     (new Uri("https://tfs2010:8080/defaultcollection")); 
    var vcs = tfs.GetService<VersionControlServer>(); 

    // Get the workspace the user has currently selected 
    var workspace = vcs.QueryWorkspaces(workspaceName, 
     vcs.AuthorizedUser, Environment.MachineName)[0]; 
    _workspace = workspace; 
    tvWksNavigator.Nodes.Clear(); 

    // Loop through all folders and get directories and files 
    foreach (var folder in workspace.Folders) 
    { 
     var info = new DirectoryInfo(folder.LocalItem); 
     if (info.Exists) 
     { 
      var rootNode = new TreeNode(info.Name) { Tag = info }; 
      GetDirectories(info.GetDirectories(), rootNode); 
      tvWksNavigator.Nodes.Add(rootNode); 
     } 
    } 
} 

使用方法QueryPendingChanges,它可能通過一個文件路徑,看看文件被掛起的更改,如果是這樣,什麼是鎖類型,也可以獲取該文件的下載詳細信息。

var status = _workspace.QueryPendingSets(new[] { new ItemSpec(
                dir.FullName, 
                RecursionType.None) }, 
                _workspace.Name, vcs.AuthorizedUser, 
          false); 
+0

這是TFVC,但不是Git ... –

相關問題