3

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://learn.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?

1

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

5 Comments

OK, creating a file and providing the complete path also creates all required folders.
how to clone repo to local folder using rest api ?
@Neo you don't.
clone i mean download all repo files folder using rest api?
1

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), e.g. typing folder1/file1 in the file name field will create a folder folder1 and a file file1.

2 Comments

While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review
@KuroNeko i posted the Link - then a summary with the fix

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.