Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Azure DevOps Services | Azure DevOps Server | Azure DevOps Server 2022
Share your code with others in Azure DevOps by using a Git repository. Clone the repo to your computer, create a branch for your changes, commit your work, and open a pull request to merge it back into the main branch.
Tip
You can use AI to help with this task later in this article, or see Enable AI assistance with Azure DevOps MCP Server to get started.
Prerequisites
| Category | Requirements |
|---|---|
| Project access | Project member. |
| Git command-line tool | One of the following Git command-line tools: - Git for Windows and Git Credential Manager. - Git for macOS or Linux. For macOS and Linux, we recommend that you configure SSH authentication. |
1. Clone the repo to your computer
When you clone a repo, you create a complete local copy so you can work offline and push changes back later. Before you clone, make sure your code is in an Azure Repos Git repository:
- No code yet — Create a new Git repo.
- Code in another Git repo (for example, GitHub) — Import it into Azure Repos.
- Code on your local computer — Create a repo, then push your code after cloning.
From your web browser, open the team project for your organization and select Repos > Files.

Select Clone, and then Copy the URL.
Open your Git command window (Git Bash on Windows) and go to the folder where you want to store the repo. Run
git clonewith the URL you copied:git clone https://FabrikamFiber01@dev.azure.com/FabrikamFiber01/FabrikamFiber01-01/_git/FabrikamFiber01-01Git downloads a copy of the code, including all commits and branches, into a new folder.
Switch to the cloned repository directory:
cd fabrikam-webKeep this command window open to work in a branch.
2. Work in a branch
Git branches isolate your changes from other work in the project. The recommended Git workflow creates a new branch for every feature or fix. The examples in this article use the branch users/jamal/feature1.
Create a branch with the
branchcommand.git branch users/jamal/feature1Use
checkoutto switch to that branch.git checkout users/jamal/feature1Tip
Create and switch in one step with
git checkout -b users/jamal/feature1. If you're working with a previously cloned repo, rungit pull origin mainfirst to ensure your branch starts from the latest code.
3. Work with the code
Edit files locally, commit your changes, and push the commit to the server.
Open the
README.mdfile in the cloned repo folder, make some changes, and Save the file.Stage and commit your changes:
git add . git commit -m "My first commit"git add .stages new and changed files.git commit -msaves them as a commit with the specified message. Git always commits to the current branch, so verify you're on the right one before committing.Push your commit to the server:
git push origin users/jamal/feature1
Your code is now in the remote repository on the users/jamal/feature1 branch. To merge it into main, create a pull request.
4. Merge your changes with a pull request
Pull requests let your team review and approve code before it merges. Create a pull request when your branch is ready for feedback - you can abandon it at any time.
In your web browser, go to your project and select Repos > Files.
Select Create a pull request in the upper-right corner. If you don't see a message like You updated users/jamal/feature1 just now, refresh your browser.

The pull request targets the default branch (
main). The title and description come from your commit message. You can add reviewers and link work items before creating.
Select Create.
Review the Overview tab, and then select Complete > Complete merge to merge your code into
main.
Note
For more information, see Create, view, and manage pull requests.
Your changes are now in main, and the users/jamal/feature1 branch is deleted from the remote repository.
View history
To see your merged changes, go to Repos > Files in the web portal and select History.

Select the Files tab and then the README file to view your changes.

Clean up
Delete your local copy of the branch after the merge completes:
git checkout main
git pull origin main
git branch -d users/jamal/feature1
These commands switch to main, pull the latest code (including your merged changes), and delete the local users/jamal/feature1 branch.
Use AI to manage Git repositories
If you configure the Azure DevOps MCP Server, you can use AI assistants to manage your Git repositories and pull requests through natural language prompts.
Example prompts for Git management
| Task | Example prompt |
|---|---|
| List repositories | List all Git repositories in <Contoso> project |
| View pull requests | Show my open pull requests in <Contoso> project |
| Check PR status | Get the status of pull request <456> in <Contoso> project |
| Find active branches | List branches with active pull requests in the <webapp> repo in <Contoso> |
| Review PR details | Show the files changed in pull request <456> in <Contoso> |
| Check build status | Show the build status for pull request <456> in <Contoso> |
| Summarize PR activity | List all pull requests merged into <main> in the <webapp> repo in <Contoso> this week |
| Find stale branches | List branches in the <webapp> repo in <Contoso> that have had no commits in the last <30> days |
| Review reviewer workload | Show how many open pull requests each team member is reviewing in <Contoso> project |