'Script that will merge changes from the master to my branch
I'm trying to write a script that will merge changes from the master to my branch that will be built in Azure DevOps
git config –global user.email "My Email"
git config –global user.name "My User Name"
REPO="$(System.TeamFoundationCollectionUri)$(System.TeamProject)/_git/$(Build.Repository.Name)"
EXTRAHEADER="Authorization: Bearer $env:SYSTEM_ACCESSTOKEN"
git -c http.extraheader="$EXTRAHEADER" clone $REPO
cd $(Build.Repository.Name)
# ls
git config http.$REPO.extraHeader "$EXTRAHEADER"
git checkout $(Build.SourceBranchName)
git status
ls -la
git merge --no-ff --no-edit origin/automatecitest
ls -la
I have configured the rights that are described in this article. but I am getting errors
*** Please tell me who you are.
Run
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
fatal: empty ident name (for <[email protected]>) not allowed
Could you please help me. Thanks.
Solution 1:[1]
Based on your actual script, you are merging origin/automatecitest to main.
I archive via below code:
trigger: none
pool:
vmImage: Ubuntu-latest
steps:
- checkout: none
- script: |
REPO="$(System.TeamFoundationCollectionUri)$(System.TeamProject)/_git/$(Build.Repository.Name)"
git clone -c http.extraheader="AUTHORIZATION: bearer $(System.AccessToken)" $REPO
cd $(Build.Repository.Name)
ls
git config user.email "[email protected]"
git config user.name "tester1"
git merge --no-ff --no-edit origin/automatecitest
ls -la
Note:
- You can change the branch, from main to other..
- The change will not push back to main branch since you need to add extra step to push. if you cat file change afte merge in the task, you can see the merge result.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | wade zhou - MSFT |


