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
+32-17Lines changed: 32 additions & 17 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.
@@ -25,7 +26,7 @@ This article shows you how to import an existing Git repo from GitHub, Bitbucket
25
26
26
27
## Import into a new repo
27
28
28
-
1.Select**Repos**, **Files**.
29
+
1.In your browser, sign in to your organization and select**Repos**, **Files**.
29
30
30
31

31
32
@@ -35,7 +36,7 @@ This article shows you how to import an existing Git repo from GitHub, Bitbucket
35
36
36
37
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.
37
38
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).
39
+
If the source repository is private but can be accessed using basic authentication (username-password, Microsoft Entra ID tokens, personal access tokens, and so on), select **Requires authorization** and enter your credentials. For enhanced security, we recommend using Microsoft Entra ID tokens when possible. 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).
@@ -81,7 +82,7 @@ az repos import create --git-source-url
81
82
|`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
83
|`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
84
|`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. |
85
+
|`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
86
|`subscription`| Name or ID of subscription. You can configure the default subscription using `az account set -s <NAME_OR_ID>`.|
86
87
|`user-name`| User name to specify when the git repository is private.|
87
88
@@ -152,7 +153,6 @@ az repos import create --git-source-url https://github.com/fabrikamprime/fabrika
152
153
153
154
## Manually import a repo using git CLI
154
155
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
156
157
157
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
158
@@ -170,7 +170,7 @@ The import repo feature was introduced in the 2017 Update 1. You can also follow
170
170
```
171
171
172
172
> [!WARNING]
173
-
> Using `--mirror` overwrites all branches in the target repo which includes deleting any branches not in the source repo.
173
+
> Using `--mirror` overwrites all branches in the target repo, which includes deleting any branches not in the source repo.
174
174
175
175
4. If the source repository has LFS objects, then fetch them, and copy them from the source repo to the target repo.
176
176
@@ -191,15 +191,31 @@ Although imports are most often successful, the following conditions might cause
191
191
192
192
* [What if my Source repository is behind two-factor authentication?](#q-what-if-my-source-repository-is-behind-two-factor-authentication)
193
193
* [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)
194
+
* [Can I import from previous on-premises versions?](#q-can-i-import-from-previous-versions)
195
195
* [Can I use MSA-based credentials?](#q-can-i-use-msa-based-credentials)
196
196
* [Can I import from TFVC?](#q-can-i-import-from-tfvc)
197
197
* [What if my source repository contains Git LFS objects?](#q-what-if-my-source-repository-contains-git-lfs-objects)
198
198
199
199
### Q: What if my source repository is behind two-factor authentication?
200
200
201
201
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.
202
+
203
+
Most Git hosting providers support authentication tokens that can be supplied to the import service:
204
+
205
+
**Microsoft Entra ID tokens (recommended):** Microsoft Entra ID tokens provide better security and are the recommended authentication method. You can obtain these tokens through:
206
+
207
+
- **Azure CLI** (for development/testing):
208
+
```bash
209
+
az account get-access-token --resource 499b84ac-1321-427f-aa17-267ca6975798 --query "accessToken" --output tsv
- Grant the application appropriate permissions in Azure DevOps
216
+
- Use the service principal credentials to obtain tokens programmatically
217
+
218
+
**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
219
204
220
<aid="multiack"></a>
205
221
@@ -211,13 +227,12 @@ This failure can happen when creating import request or while import is in progr
211
227
212
228
### Q: Can I import from previous versions?
213
229
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
-
230
+
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.
231
+
217
232
### Q: Can I use MSA-based credentials?
218
233
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
234
+
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.
235
+
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