Hey, here are some key steps that you should follow:
Grant version control permissions to the build service
Are you interested in learning Azure from basics! Here's the right video for you on Azure provided by Intellipaat:
Go to the Version Control control panel tab
Team Services: https://{your-account}.visualstudio.com/DefaultCollection/{your-team-project}/_admin/_versioncontrol
On-premises: https://{your-server}:8080/tfs/DefaultCollection/{your-team-project}/_admin/_versioncontrol
On the Version Control tab, select the repository in which you want to run Git commands, and then select Project Collection Build Service (account_name). Grant permissions needed for the Git commands you want to run. Typically you'll want to grant:
Branch creation: Allow
Contribute: Allow
Read: Inherited allow
Tag creation: Inherited allow
When you're done granting the permissions, make sure to click Save changes.
Enable your build definition to run Git.exe
On the variables tab set this variable: system.prefergit = true
On the options tab select Allow scripts to access OAuth token.
Also, make sure to follow this document: https://www.visualstudio.com/en-us/docs/build/scripts/git-commands