Share via


Create a new Git repo in your project

Azure DevOps Services | Azure DevOps Server | Azure DevOps Server 2022 | Azure DevOps Server 2020

Azure DevOps projects contain Git repositories, work items, builds, and releases. You can use Git repos in your projects to manage your source code as your project grows. This guide shows you how to create a Git repo using the web portal.

Prerequisites

Category Requirements
Organization An organization in Azure DevOps with a Git repository.
Permissions Create repository permissions, granted by default to project administrators. For more information, see Set Git repository permissions.
Tools - Git for Windows, which includes Git Credential Manager, or Git for macOS and Linux. For macOS and Linux, we recommend configuring SSH authentication.

Create a repo using the web portal

Clone the repo to your computer

To work with a Git repo, you clone it to your computer. Cloning a repo creates a complete local copy of the repo for you to work with. Cloning also downloads all commits and branches in the repo and sets up a named relationship with the repo on the server. Use this relationship to interact with the existing repo, pushing and pulling changes to share code with your team.

Work with the code

In this step, we make a change to the files on your computer, commit the changes locally, push the commit up to the repo on the server, and view the changes there.

  1. Browse to the folder on your computer where you cloned the repo and open the README.md file in your editor of choice.

  2. Make some changes, for example add This is my first edit. to the file, and save and close the file.

  3. In the Git command window, navigate to the fabrikam-fiber directory by entering the following command:

    cd fabrikam-fiber
    
  4. Commit your changes by entering the following command in the Git command window:

    git commit -a -m "My first commit"
    

    When you use git commit, -a means to commit all changed files, and -m specifies a commit message.

  5. Push your changes up to the Git repo by entering the following command into the Git command window:

    git push
    
  6. Switch back to the web portal and select History from the Code view to view your new commit. The new repo has two commits. The first is the commit where the README and .gitignore were added when the repo was created. The second is the commit you just made.

    Screenshot of View commit history.

  7. Switch to the Files tab and select the README file to view your changes.

    Screenshot of Files page, View changed file.

Next steps