List all directories with the branch details

# Specify the directory path
$directoryPath = "C:\Your\Directory\Path"

# Change to the specified directory
Set-Location -Path $directoryPath

# Get the list of subdirectories
$subDirectories = Get-ChildItem -Directory

# Loop through each subdirectory
foreach ($subDirectory in $subDirectories) {
    # Get the last updated date of the subdirectory
    $lastUpdated = $subDirectory.LastWriteTime

    # Change to the subdirectory
    Set-Location -Path $subDirectory.FullName

    # Get the current Git branch
    $gitBranch = git rev-parse --abbrev-ref HEAD

    # Print the subdirectory, last updated date, and Git branch in a "|" separated format
    Write-Host "$($subDirectory.Name)|$lastUpdated|$gitBranch"

Leave a Reply

Your email address will not be published. Required fields are marked *