microsoft / azure-devops-dotnet-samples

.NET/C# samples for integrating with Azure DevOps Services and Azure DevOps Server
https://docs.microsoft.com/azure/devops/integrate
MIT License
519 stars 511 forks source link

Git - How to download the entire files from a particular commit #282

Open estoysol opened 4 years ago

estoysol commented 4 years ago

I was trying to download the entire code/files from a particular commit, which is present in a branch, which is inside a repository. I was trying to use gitClient.GetItemZipAsync, but getting an error like One or more errors occurred. (TF401174: The item 'http://path/projectName/_git/Repositoryname/commit/commitId' could not be found in the repository 'RepositoryName' at the version specified by '' (resolved to commit 'commitId')) . I have repository id, but I needed the files from a commit id that is inside a branch. Used the below code foreach (var commit in commits) { GitVersionDescriptor gitVer = new GitVersionDescriptor() { VersionType = GitVersionType.Commit, VersionOptions = GitVersionOptions.None, Version = commit.CommitId }; Stream s = gitClient.GetItemZipAsync(projectId, repo.Id, commit.RemoteUrl,null, recursionLevel: VersionControlRecursionType.None, includeContentMetadata: false, latestProcessedChange: false, download: false, versionDescriptor: gitVer).Result;

Thanks