I have a simple PowerShell script to keep a folder up-to-date with its git repository.
Param(
[Parameter(Mandatory = $true)][string]$branch,
[string]$location,
[int]$depth
)
Get-ChildItem -Recurse -Directory -Depth $depth -Filter _$branch -Name -Path $location |
ForEach-Object {
Write-Output "`n$("{0:MM/dd/yy} {0:HH:mm:ss}" -f (Get-Date)): Getting latest from $location$_"
git -C $location$_ pull
} *>> logs\$branch.log
It works fine when the repository is already up-to-date. However, when it isn't, this is the output:
07/29/19 14:47:27: Getting latest from somepath git : From https://gitlab.com/someplace At someplace\UpdateBranch.ps1:10 char:5 + git -C $location$_ pull + ~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (From https://gi...n/somerepo:String) [], RemoteException + FullyQualifiedErrorId : NativeCommandError b34e5d0..3ec9561 develop -> origin/develop b6d33b1..65fb520 feature/feature1 -> origin/feature/feature1 * [new branch] feature/feature2 -> origin/feature/feature2 c3fe1c9..9553b72 master -> origin/master Updating b34e5d0..3ec9561 Fast-forward stylesheet.scss | 4 ++-- ... 6 files changed, 11 insertions(+), 10 deletions(-)
It seems to do the update but also outputs an error.