I wrote the following PowerShell script to do so:
$content = type .gitignore | % { $_.Trim() } | ? { $_.StartsWith('/') } | % { $_.SubString(1) }
$content | % {
$folder = split-path -Parent $_
if($folder.length -gt 0) {
if(-not (test-path $folder)) {
md $folder | Out-Null
}
$pattern = split-path -Leaf $_
$newPattern = '/' + $pattern
$ignoreFile = "$folder\.gitignore"
$exists = $false
if((test-path $ignoreFile ) -and (type $ignore) -notcontains $newPattern) {
$exists = $true
}
if(!$exists) {
Add-Content -Force -Path $ignoreFile $newPattern
}
}
}
0 comments:
Post a Comment