简体   繁体   中英

Azure DevOps: How to create a folder in GIT repo with REST API repo

I want to create a folder hierarchy in a GIT repository on Azure Devops using the REST API. (automated via a script)

The docs https://docs.microsoft.com/en-us/rest/api/azure/devops/git/pushes/create?view=azure-devops-rest-6.1 provide only examples how you can create files, but not folders.

Does anyone know how to do that?

You can't. Git tracks files in a tree structure. If there is no file (leaf), there is no folder (tree-branch).

So you'll need to add at least one file to the empty folder.

Hence the way to create a folder with the REST API, is to create a file with a new folder as its root.

This thread might help you out with your problem:

How do I create a folder in a GitHub repository?

Basicly use / in the file name field to create folder(s), eg typing folder1/file1 in the file name field will create a folder folder1 and a file file1.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM