I have been working on a PowerShell script that goes through all my git directories, with a goal of if there any changes to the remote, perform a pull and then compile the source.
I have a working script but when I did a manual pull I found that I was not pulling the information.
One of the repositories I pull from is the boost repository (https://github.com/boostorg/boost.git). This project has a main project and number of sub projects.
I am running this through PowerShell on Windows. I also have posh-git installed.
The first thing the script does is a cd
into the git directory (... Boost\boost-git). After that I perform the following:
Write-Host "git status"
git status
Write-Host "git branch"
git branch
$RemoteBranch = git remote
Write-Host "Remote : '$RemoteBranch'"
if ($RemoteBranch -ne $null) {
$RemoteURL = git remote get-url --all $RemoteBranch
Write-Host "Remote URL : '$RemoteURL'"
}
Write-Host "`ngit branch | ForEach-Object { Get-GitStatus $_. }"
git branch | ForEach-Object {
$status = Get-GitStatus $_.
$status
$BehindBy += $status.BehindBy
}
Write-Host "`ngit diff-index --quiet HEAD"
$GitHead = git diff-index --quiet HEAD
$GitHead
if ($GitHead -ne "") {
Write-Host "`nNo Changes"
} else {
Write-Host "`nChanges"
$GitHead
}
Write-Host "`nBehindBy Sum $BehindBy"
if ($BehindBy -gt 0) {
git fetch --all
}
While the script runs, I am not pulling the repository when the remote has been updated.
Any help would be greatly appreciated or let me know which commands I should be parsing.