我需要在部署完成后通过 azure 管道自动 merge 。
例如:我有一个分支 - 'release/1.0.0
' 用于部署,部署后该分支需要自动 merge 到主分支中,无需任何 pull 请求。
我正在使用 bash 任务来执行 git 命令,如下所示:
- ${{ if startsWith(variables['Build.SourceBranch'], 'refs/heads/release/') }}:
- task: Bash@3
displayName: "Auto merge release"
name: "Auto_merge"
inputs:
targetType: "inline"
script: |
git config --global user.name "AzureDevOps Agent"
git config --global user.email "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="84fdebf1c4e1fce5e9f4e8e1aae7ebe9" rel="noreferrer noopener nofollow">[email protected]</a>"
git checkout origin/main
git fetch
git merge --ff $(Build.SourceBranchName)
git push origin
这是 azure 管道中的错误:
你能帮我解决这个问题吗?
注意:我不想创建任何 pull 请求来处理自动 merge ,只是不想让 ADO 中的 pull 请求变得困惑。
我想通过 git merge
来实现这一点,而不需要任何 pull 请求
最佳答案
关于 git merge,有一个option --ff
,但不是 -ff
。
With
--ff
, when possible resolve the merge as a fast-forward (only update the branch pointer to match the merged branch; do not create a merge commit). When not possible (when the merged-in history is not a descendant of the current history), create a merge commit.
确保使用正确的语法。
关于git - 在 Azure .yml 管道中使用 git 命令自动 merge ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74697562/