Last active
March 28, 2017 22:58
-
-
Save nathanbedford/4e126e81d9ff183cf68e to your computer and use it in GitHub Desktop.
Reinitializes all the git repositories in a given folder. Is recursive by default.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $gitProjectsFolder = "c:\stash" | |
| "Building up folder list. This may take a minute..." | |
| # this will search for git repos up to 4 levels deep | |
| # (not using -Depth so we can support Powershell v4) | |
| $projectFolders = Get-ChildItem $gitProjectsFolder\*,$gitProjectsFolder\*\*,$gitProjectsFolder\*\*\*,$gitProjectsFolder\*\*\*\* -Hidden -Directory | |
| function DeleteIfExists($file){ | |
| If(Test-Path $file){ | |
| Remove-Item $file -Force | |
| } | |
| } | |
| foreach ($folder in $projectFolders ) | |
| { | |
| If( $folder.FullName.EndsWith(".git")){ | |
| DeleteIfExists "$folder.FullName\hooks\prepare-commit-msg" | |
| DeleteIfExists "$folder.FullName\hooks\prepare-commit-msg.cmd" | |
| & 'git' "init" "$($folder.Parent.FullName)" | |
| } | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updated to remove old hooks first, so we can spread new hook changes easily to all repos