I have main dev
branch and I want to use pipeline to merge dev into some branch via common shell script.
Pipeline snippet is below:
steps:
- checkout: self
clean: true
persistCredentials: true
- task: Bash@3
displayName: "dev merging to source branch"
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
BRANCH: *
inputs:
targetType: "inline"
script: |
git config --global user.email "..."
git config --global user.name "..."
git remote -v
git pull
git checkout dev
git checkout $BRANCH
git status
git merge $BRANCH dev
git status
git push origin HEAD:origin/task/temp_branch
But I got different errors (for example like this):
HEAD is now at f7d3f878 Update auto-merge-v4.yml for Azure Pipelines
HEAD detached at origin/task/temp_branch
nothing to commit, working tree clean
Merge made by the 'ort' strategy.
...
.../src/core/... | 2 +-
...
6 files changed, 28 insertions(+), 12 deletions(-)
HEAD detached from origin/task/temp_branch
nothing to commit, working tree clean
To https://dev.azure.com/quantori/org-skill-matrix-service/_git/org-skill-matrix-service-v4
! [rejected] HEAD -> origin/task/temp_branch (fetch first)
error: failed to push some refs to 'https://dev.azure.com/quantori/org-skill-matrix-service/_git/org-skill-matrix-service-v4'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
What am I doing in wrong way? In my view everything is logical and right. Are there any best practices to do such a tasks?