在 GIT 推送到 TFS-GIT 期间隐藏来自远程 tfs-git 的响应

Hiding response from remote tfs-git during GIT Push to TFS-GIT

我正在尝试将 git-hub 存储库(由远程团队使用)中的文件同步到 TFS 中的本地 git 存储库。

为此,我使用以下命令:

REM Public GIT repository
git remote set-url  origin https://github.com/<user>/<Project>.git
REM Private GIT repository
git remote set-url targettfs  http://LocalServer:8080/tfs/DefaultCollection/_git/<ProjectName>

REM Pull updates from GITHUB
git reset --hard HEAD  
git fetch origin --quiet
git pull origin master --quiet

REM Sync TFS-GIT to local
git init
git reset --hard HEAD  
git fetch targettfs --quiet
git pull targettfs master --quiet
git add .
git commit -m "sync file with github" --quiet

REM Push updates to GIT repository in TFS
git push origin master  --quiet

这个脚本按预期完成了主要任务,这里的问题是在执行此操作时我得到的一些响应在控制台中被写回,如下所示:

为此,我尝试使用 TFS 推送 --quiet,但没有用

根据您的屏幕截图,TFS Build 将 git 输出视为错误。请检查答案 :

Git outputs its content to the error stream which Visual Studio Team Services interprets as error.

You need to redirect Gits output in your script like this to make it working:

git pull 2>&1 | Write-Host