Table of Contents
Where is my directory structure in Azure DevOps?
This was a nice one. I was asked to create a new repository in Azure DevOps and to think about the structure.
I started in good spirits with creating the repository and started organizing the folder structure and the ideas I had.
I then tried to sync the new folder structure to the git in Visual Studio Code, but the directories themselves did not appear in the DevOps repository online.

I was a bit surprised. Ran a test in another DevOps where I still had some items to be synced an voila. It did work there.
I then clone the repository again to Visual Studio Code, but again no success. The next step was to create the directory online and see if I could get it synced to my local device.
When creating one of the folders online, I immediately saw what my problem was.

“Git folders cannot be empty, so a placeholder file will be added its content can be edited before commit.“
Can we also automate the creation of these items?
Yes we can!
I mainly use my repository for PowerShell, so I will also explain below how you can solve this with PowerShell.
For the dummies among us,
- Go to Start,
- Open PowerShell_ISE,
- Open a new tab,
- Copy / paste the following command to PowerShell_ISE.
$Path = 'C:\temp\Repository'
Set-Location -Path $Path
Change the ‘Path’ to where your repository is cloned.
Now, copy / paste the rest of the script.
$items = Get-Childitem
foreach ($item in $items){
New-Item -Name "$($item.Name).txt" -Path $item.FullName -ItemType File
}
You can change the .txt to any file extension you want (as long as it’s not a directory).
So, the full script will be:
$Path = 'C:\temp\Repository'
Set-Location -Path $Path
$items = Get-Childitem
foreach ($item in $items){
New-Item -Name "$($item.Name).txt" -Path $item.FullName -ItemType File
}
Run the script by pressing F5 in PowerShell_ISE.
Now sync or push your repository again and they will be in the online version this time.