8

我正在编写一个需要同时将代码推送到多个 git 存储库的 powershell 脚本?

这是我到目前为止的脚本:

param(
    [parameter(Mandatory=$true)]
    [string]$repoPath,
    [parameter(Mandatory=$true)]
    [array]$remoteRepos
)

pushd $repoPath
$remoteRepos | % { 
    #Want to exexcute this without blocking
    & git push $_ master --fore -v 
}
popd

这是我执行脚本的方式:

gitdeploy.ps1 -repoPath c:\code\myrepo -remoteRepos repo1,repo2

如何以& git push $_ master --fore -v非阻塞方式执行?

解决方案

感谢@Jamey 的解决方案。我执行了这个命令:

Start-Process "cmd.exe" "/c git push $_ master --force -v"
4

3 回答 3

9

您还可以使用 start-process 在附加命令窗口中运行每次推送。

start-process -FilePath "git" -ArgumentList ("push", $_,  "master", "--fore", "-v") 
于 2012-05-17T17:02:11.523 回答
3

Micah,您可以使用 start-job 在后台运行它 - http://technet.microsoft.com/en-us/library/dd347692.aspx

于 2012-05-17T16:47:05.677 回答
0

怎么样start git "push $_ master --force -v"

于 2019-09-13T22:40:29.870 回答