You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/repos/git/go-install.md
+47-13Lines changed: 47 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,17 +1,19 @@
1
1
---
2
-
title: Go install support
2
+
title: Use Go install command support with Azure Repos Git
3
3
titleSuffix: Azure Repos
4
-
description: Learn how to use Go install command with Azure Repos Git
4
+
description: Learn how to use the Go install command with Azure Repos Git repositories using SSH keys, Microsoft Entra ID tokens, or personal access tokens for authentication.
5
+
ai-usage: ai-assisted
5
6
ms.service: azure-devops-repos
6
7
ms.topic: conceptual
7
-
ms.date: 02/26/2025
8
-
monikerRange: '>= azure-devops-2020'
8
+
ms.date: 07/02/2025
9
+
monikerRange: '<= azure-devops'
9
10
ms.subservice: azure-devops-repos-git
11
+
# customer-intent: As a Go developer, I want to use the go install command to download packages from Azure Repos Git repositories so I can manage dependencies in my Go projects with proper authentication.
10
12
---
11
13
12
-
# Go install command support in Azure Repos Git
14
+
# Use Go install command support in Azure Repos Git
Go is an open-source programming language, also referred to as Golang.
17
19
In Go, you can use the `install` command to download and install packages and dependencies.
@@ -20,9 +22,6 @@ With `go install`, you're able to download packages with their dependencies name
20
22
You can also use the `import` key word inside a go file to specify the import path, using the
21
23
same syntax described in the following sections.
22
24
23
-
> [!NOTE]
24
-
> The feature documented in this article requires Azure DevOps Server 2019 Update 1 or later version.
25
-
26
25
## Go install with public projects
27
26
28
27
If your Azure Repos Git repo is in a [public project](../../organizations/projects/about-projects.md), you can use `go install` using the web repo url in the following format. For version, you can use `latest` or a specific version.
@@ -42,10 +41,10 @@ go install dev.azure.com/<organization>/<project>/_git/<repo>.git/subfolder1/sub
42
41
43
42
## Go install with private projects
44
43
45
-
If your Azure DevOps Git repo is private, you can either use SSH or authenticate with a Personal Access Token (PAT) for HTTPS.
44
+
If your Azure Repos Git repository is private, you can authenticate using SSH keys, Microsoft Entra ID tokens (recommended), or Personal Access Tokens (PATs).
46
45
47
46
> [!IMPORTANT]
48
-
> To access private Azure Repos Git repositories using go install, you must first set the environment variable `GOPRIVATE=dev.azure.com`. You can set this environment variable locally before building or running.
47
+
> To access private Azure Repos Git repositories using `go install`, you must first set the environment variable `GOPRIVATE=dev.azure.com`. You can set this environment variable locally before building or running.
49
48
50
49
### SSH
51
50
@@ -70,9 +69,44 @@ go install dev.azure.com/<organization>/<project>/<repo>.git
70
69
71
70
### HTTPS
72
71
73
-
To use HTTPS with `go install`, you must create a PAT as described in [Authenticate access with personal access tokens](../../organizations/accounts/use-personal-access-tokens-to-authenticate.md). This PAT requires only the **Code (read)**[scope](../../integrate/get-started/authentication/oauth.md#scopes).
72
+
To use HTTPS with `go install`, you can authenticate using either Microsoft Entra ID tokens (recommended) or Personal Access Tokens (PATs).
73
+
74
+
#### Microsoft Entra ID tokens (recommended)
75
+
76
+
Microsoft Entra ID tokens provide better security and are the recommended authentication method. You can obtain these tokens through:
77
+
78
+
-**Azure CLI** (for development/testing):
79
+
```bash
80
+
az account get-access-token --resource 499b84ac-1321-427f-aa17-267ca6975798 --query "accessToken" --output tsv
The `<user>` part can be any nonempty string; we suggest using `entra` or your username.
99
+
100
+
> [!TIP]
101
+
> **Get a one-time Microsoft Entra token from Azure CLI**: You can quickly obtain a Microsoft Entra ID token for Git operations using the Azure CLI, which is useful for development and testing scenarios. When generating tokens on behalf of a service principal, make sure to [sign in as the service principal](/cli/azure/authenticate-azure-cli) first.
102
+
>
103
+
> **Token management**: Microsoft Entra ID tokens have expiration times, so you might need to refresh them periodically. For automated workflows, consider using service principals with appropriate token refresh mechanisms.
104
+
105
+
#### Personal Access Tokens (alternative)
106
+
107
+
If you prefer to use PATs, create a PAT as described in [Authenticate access with personal access tokens](../../organizations/accounts/use-personal-access-tokens-to-authenticate.md). This PAT requires only the **Code (read)**[scope](../../integrate/get-started/authentication/oauth.md#scopes).
74
108
75
-
After you create the PAT, add this entry to your.gitconfig file:
109
+
After you create the PAT, add this entry to your`.gitconfig` file:
Copy file name to clipboardExpand all lines: docs/repos/git/import-git-repository.md
+43-27Lines changed: 43 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,16 +1,17 @@
1
1
---
2
-
title: Import a Git repo into your project
2
+
title: Import a Git repository into a project
3
3
titleSuffix: Azure Repos
4
-
description: Import a repo from GitHub, GitLab, or Bitbucket into your project in Azure DevOps.
4
+
description: Import a Git repository from GitHub, GitLab, Bitbucket, or other locations into your Azure DevOps project using secure authentication methods including Microsoft Entra ID tokens.
5
5
ms.assetid: 5439629e-23fd-44f1-a345-f00a435f1430
6
6
ms.service: azure-devops-repos
7
-
ms.topic: quickstart
7
+
ms.topic: how-to
8
8
monikerRange: '<= azure-devops'
9
-
ms.date: 02/14/2025
9
+
ms.date: 07/02/2025
10
10
ms.subservice: azure-devops-repos-git
11
+
# customer-intent: As a developer, I want to import an existing Git repository from GitHub, GitLab, or other providers into Azure DevOps so I can consolidate my source code and use Azure DevOps features for my project.
> When the import of the repository is completed, Azure DevOps sets the **Default** branch for that imported repository. If the imported repository contains a branch named `main`, it gets set as the default branch, otherwise the first branch (in alphabetical order) of the imported repository gets set as **Default**.
25
30
26
-
## Import into a new repo
31
+
1. In your browser, sign in to your organization and select **Repos** > **Files**.
27
32
28
-
1. Select **Repos**, **Files**.
29
-
30
-

33
+

31
34
32
35
2. From the repo drop-down, select **Import repository**.
3.If the source repo is publicly available, just [enter the clone URL](clone.md#clone_url) of the source repository and a name for your new Git repository.
39
+
3.[Enter the clone URL](clone.md#clone_url) of the source repository and a name for your new Git repository.
37
40
38
-
If the source repository is private but can be accessed using basic authentication (username-password, personal access token, etc.), select **Requires authorization** and enter your credentials. SSH authentication isn't supported, but you can manually import a repository that uses SSH authentication by following the steps in [Manually import a repo using git CLI](#manual-import-git-cli).
41
+

On the **Files** page of the empty Git repository, select **Import** and [enter the clone URL](clone.md#clone_url). Provide credentials if the source repository requires authentication.
47
50
48
-

51
+

49
52
50
53
> [!NOTE]
51
54
> The import feature disables automated linking for work items mentioned in a commit comment since the work item IDs in the destination project might not be the same as ones in the source project. Automatic linking for work items mentioned in a commit can be re-enabled by navigating to **Settings**, **Version Control**, selecting your repository, and choosing **Options**. For more information on linking commits with work items, see [Link work items to commits](share-your-code-in-git-vs.md#link-work-items)
@@ -56,8 +59,7 @@ On the **Files** page of the empty Git repository, select **Import** and [enter
56
59
57
60
You can use [az repos import](/cli/azure/repos/import#az-repos-import-create) to import a repository to your Azure DevOps project.
58
61
59
-
> [!NOTE]
60
-
> You must first create the repository in Azure DevOps before you can import a Git repository. Also, the repository you create must be empty. To create a repo, see [Create your Git repo in Azure Repos](share-your-code-in-git-cmdline.md#create-your-git-repo-in-azure-repos).
62
+
You must first create the repository in Azure DevOps before you can import a Git repository. Also, the repository you create must be empty. To create a repo, see [Create your Git repo in Azure Repos](share-your-code-in-git-cmdline.md#create-your-git-repo-in-azure-repos).
61
63
62
64
```azurecli
63
65
az repos import create --git-source-url
@@ -81,7 +83,7 @@ az repos import create --git-source-url
81
83
|`org`, `organization`| Azure DevOps organization URL. You can configure the default organization by using `az devops configure -d organization=<ORG_URL>`. **Required** if not configured as default or picked up via git config. Example: `https://dev.azure.com/MyOrganizationName/`.|
82
84
|`project`, `p`|Name or ID of the project. You can configure the default project using `az devops configure -d project=<NAME_OR_ID>`. **Required** if not configured as default or picked up via git config.
83
85
|`repository`| Name or ID of the repository to create the import request in. |
84
-
|`requires-authorization`| Flag to indicate if the source git repository is private. If you require authentication, then generate an authentication token on the source repo and set the environment variable `AZURE_DEVOPS_EXT_GIT_SOURCE_PASSWORD_OR_PAT` to the value of the token. Then the import request includes authentication. |
86
+
|`requires-authorization`| Flag to indicate if the source git repository is private. If you require authentication, then generate an authentication token on the source repo and set the environment variable `AZURE_DEVOPS_EXT_GIT_SOURCE_PASSWORD_OR_PAT` to the value of the token. For enhanced security, we recommend using Microsoft Entra ID tokens when possible. Then the import request includes authentication. |
85
87
|`subscription`| Name or ID of subscription. You can configure the default subscription using `az account set -s <NAME_OR_ID>`.|
86
88
|`user-name`| User name to specify when the git repository is private.|
87
89
@@ -152,7 +154,6 @@ az repos import create --git-source-url https://github.com/fabrikamprime/fabrika
152
154
153
155
## Manually import a repo using git CLI
154
156
155
-
The import repo feature was introduced in the 2017 Update 1. You can also follow these steps to manually import a repo into an Azure DevOps Services repo by replacing "TFS" with Azure Repos in the following steps.
156
157
157
158
1. Clone the source repo to a temporary folder on your computer using the `bare` option, as shown in the following command line example, and then navigate to the repo's folder. When cloning using the `bare` option, the folder name includes the `.git` suffix. In this example, `https://github.com/contoso/old-contoso-repo.git` is the source repo to be manually imported.
158
159
@@ -170,7 +171,7 @@ The import repo feature was introduced in the 2017 Update 1. You can also follow
170
171
```
171
172
172
173
> [!WARNING]
173
-
> Using `--mirror` overwrites all branches in the target repo which includes deleting any branches not in the source repo.
174
+
> Using `--mirror` overwrites all branches in the target repo, which includes deleting any branches not in the source repo.
174
175
175
176
4. If the source repository has LFS objects, then fetch them, and copy them from the source repo to the target repo.
176
177
@@ -191,15 +192,31 @@ Although imports are most often successful, the following conditions might cause
191
192
192
193
* [What if my Source repository is behind two-factor authentication?](#q-what-if-my-source-repository-is-behind-two-factor-authentication)
193
194
* [What if my source repository doesn't support multi_ack?](#multiack)
194
-
* [Can I import from previous versions of Team Foundation Server?](#q-can-i-import-from-previous-versions)
195
+
* [Can I import from previous on-premises versions?](#q-can-i-import-from-previous-versions)
195
196
* [Can I use MSA-based credentials?](#q-can-i-use-msa-based-credentials)
196
197
* [Can I import from TFVC?](#q-can-i-import-from-tfvc)
197
198
* [What if my source repository contains Git LFS objects?](#q-what-if-my-source-repository-contains-git-lfs-objects)
198
199
199
200
### Q: What if my source repository is behind two-factor authentication?
200
201
201
202
A: The import service uses REST APIs to validate and trigger import and can't work directly with repositories that require two-factor authentication.
202
-
Most Git hosting providers like [GitHub](https://help.github.com/articles/creating-an-access-token-for-command-line-use/) and [Azure DevOps Services](../../organizations/accounts/use-personal-access-tokens-to-authenticate.md) support personal tokens which can be supplied to the import service.
203
+
204
+
Most Git hosting providers support authentication tokens that can be supplied to the import service:
205
+
206
+
**Microsoft Entra ID tokens (recommended):** Microsoft Entra ID tokens provide better security and are the recommended authentication method. You can obtain these tokens through:
207
+
208
+
- **Azure CLI** (for development/testing):
209
+
```bash
210
+
az account get-access-token --resource 499b84ac-1321-427f-aa17-267ca6975798 --query "accessToken" --output tsv
- Grant the application appropriate permissions in Azure DevOps
217
+
- Use the service principal credentials to obtain tokens programmatically
218
+
219
+
**Personal Access Tokens (alternative):**[GitHub](https://help.github.com/articles/creating-an-access-token-for-command-line-use/) and [Azure DevOps](../../organizations/accounts/use-personal-access-tokens-to-authenticate.md) also support personal access tokens.
203
220
204
221
<aid="multiack"></a>
205
222
@@ -211,13 +228,12 @@ This failure can happen when creating import request or while import is in progr
211
228
212
229
### Q: Can I import from previous versions?
213
230
214
-
A: If the source Git repository is in a TFS version earlier than TFS 2017 RTM, then import fails.
215
-
This happens because of a contract mismatch between the latest Azure DevOps and previous versions.
216
-
231
+
A: If the source Git repository is in an on-premises version earlier than 2017 RTM, then the import fails, due to a contract mismatch between the latest Azure DevOps and previous versions.
232
+
217
233
### Q: Can I use MSA-based credentials?
218
234
219
-
A: Unfortunately, MSA (Microsoft Account, formerly Live ID) based credentials don't work. Import service relies on basic authentication to communicate with the source repository. If the username / password you're using aren't basic auth then authentication and import fail.
220
-
One way to check if the username / password you're using are basic auth or not is to try using Git to clone your repository using the following format
235
+
A: Unfortunately, MSA (Microsoft Account) based credentials don't work. Import service relies on basic authentication to communicate with the source repository. If the username and password you're using aren't basic auth, then authentication and import fail.
236
+
One way to check whether the username / password you're using are basic auth is to try using Git to clone your repository using the following format:
0 commit comments