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
* Start work
* add image
* Add information about new settings
* Update date
* The window is restored to the same position
* add link
* Resize to 70% in paint.net
* Acrolinx
* add images
* Tweak wording
* Set moniker zones
* Fix moniker range
* Add default branch name
* Add version of VS
* Fix image link
* Update docs/version-control/git-settings.md
Co-authored-by: Jullyana Ramos <[email protected]>
* Update docs/version-control/git-settings.md
* Update docs/version-control/git-settings.md
Co-authored-by: aamarsh <[email protected]>
* Update docs/version-control/git-settings.md
* Update docs/version-control/git-settings.md
* Update docs/version-control/git-settings.md
---------
Co-authored-by: Jullyana Ramos <[email protected]>
Co-authored-by: aamarsh <[email protected]>
Copy file name to clipboardExpand all lines: docs/version-control/git-settings.md
+72-9Lines changed: 72 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
title: Git settings in Visual Studio
3
3
titleSuffix: ""
4
4
description: Explore how Visual Studio uses .gitconfig files and Git settings to manage your project and solution preferences, such as your preferred diff and merge tools.
5
-
ms.date: 04/04/2024
5
+
ms.date: 5/5/2025
6
6
ms.topic: conceptual
7
7
author: ghogen
8
8
ms.author: ghogen
@@ -23,7 +23,13 @@ You can configure two types of settings:
23
23
24
24
1. To configure Git settings in Visual Studio, choose **Settings** from the top-level Git menu.
25
25
26
+
:::moniker range=">=vs-2022"
27
+
:::image type="content" source="media/vs-2022/git-menu-settings.png" alt-text="The Git menu with a callout to the Settings command.":::
28
+
:::moniker-end
29
+
30
+
:::moniker range="<=vs-2019"
26
31
:::image type="content" source="media/git-menu-settings.png" alt-text="The Git menu with a callout to the Settings command.":::
32
+
:::moniker-end
27
33
28
34
2. Choose **Git Global Settings** or **Git Repository Settings** to view and configure global-level or repository-level settings.
29
35
@@ -52,7 +58,7 @@ You can also configure and check some of the most common Git configuration setti
52
58
53
59
### Name and email
54
60
55
-
The name and email that you provide will be used as the committer information for any commit you make. This setting is available at both global and repository scopes, and corresponds to the `git config`[user.name](https://git-scm.com/docs/git-config#Documentation/git-config.txt-username) and [user.email](https://git-scm.com/docs/git-config#Documentation/git-config.txt-useremail) settings.
61
+
The name and email that you provide is used as the committer information for any commit you make. This setting is available at both global and repository scopes, and corresponds to the `git config`[user.name](https://git-scm.com/docs/git-config#Documentation/git-config.txt-username) and [user.email](https://git-scm.com/docs/git-config#Documentation/git-config.txt-useremail) settings.
56
62
57
63
1. From the Git menu, go to **Settings**. To set your user name and email at the global level, go to **Git Global Settings**; to set your user name and email at the repository level, go to **Git Repository Settings**.
58
64
@@ -120,7 +126,7 @@ Here's how to change the settings:
120
126
121
127
### Credential helper
122
128
123
-
When Visual Studio performs a remote Git operation, the remote endpoint might reject the request because it requires credentials to be provided with the request. At that time, Git invokes a credential helper, which will return the credentials needed to perform the operation, and then will try the request again. The credential helper used corresponds to the `git config`[credential.helper](https://git-scm.com/docs/gitcredentials) setting. It is available at the global scope with the following values:
129
+
When Visual Studio performs a remote Git operation, the remote endpoint might reject the request because it requires credentials to be provided with the request. At that time, Git invokes a credential helper, which returns the credentials needed to perform the operation, and then tries the request again. The credential helper used corresponds to the `git config`[credential.helper](https://git-scm.com/docs/gitcredentials) setting. It is available at the global scope with the following values:
124
130
125
131
-**GCM for Windows**: Use [Git Credential Manager for Windows](https://github.com/microsoft/Git-Credential-Manager-for-Windows) as the helper.
126
132
-**GCM Core**: Use [Git Credential Manager Core](https://github.com/microsoft/Git-Credential-Manager-Core) as the helper.
@@ -136,7 +142,7 @@ Here's how to change the settings:
136
142
137
143
### Diff & merge tools
138
144
139
-
Git will show diffs and merge conflicts in your preferred tools. The settings in this section correspond to the `git config`[diff.tool](https://git-scm.com/docs/git-config#Documentation/git-config.txt-difftool) and [merge.tool](https://git-scm.com/docs/git-config#Documentation/git-config.txt-mergetool) settings. You can configure Git to use Visual Studio as your merge or diff tool in **Git Global Settings** and **Git Repository Settings** by selecting **Use Visual Studio**. To configure other diff and merge tools, use `git config` with the [diff.tool](https://git-scm.com/docs/git-config#Documentation/git-config.txt-difftool) or [merge.tool](https://git-scm.com/docs/git-config#Documentation/git-config.txt-mergetool) switch.
145
+
Git shows diffs and merge conflicts in your preferred tools. The settings in this section correspond to the `git config`[diff.tool](https://git-scm.com/docs/git-config#Documentation/git-config.txt-difftool) and [merge.tool](https://git-scm.com/docs/git-config#Documentation/git-config.txt-mergetool) settings. You can configure Git to use Visual Studio as your merge or diff tool in **Git Global Settings** and **Git Repository Settings** by selecting **Use Visual Studio**. To configure other diff and merge tools, use `git config` with the [diff.tool](https://git-scm.com/docs/git-config#Documentation/git-config.txt-difftool) or [merge.tool](https://git-scm.com/docs/git-config#Documentation/git-config.txt-mergetool) switch.
140
146
141
147
:::image type="content" source="media/tools-setting.png" alt-text="Screenshot that shows the section to set default Diff tool and Merge tool in the Options dialog box.":::
142
148
@@ -160,39 +166,84 @@ To view all of your other Git configuration settings, you can open and view the
160
166
161
167
The following settings manage Git-related preferences in Visual Studio, and are managed by Visual Studio instead of Git configuration files. All of the settings in this section are configured in the **Git Global Settings** page.
162
168
169
+
:::moniker range=">=vs-2022"
170
+
163
171
-[Default location](#default-location)
172
+
-[Default branch name](#default-branch-name)
164
173
-[Close open solutions not under Git when opening a repository](#close-open-solutions-not-under-git-when-opening-a-repository)
-[Open folder in Solution Explorer when opening a Git repository](#open-folder-in-solution-explorer-when-opening-a-git-repository)
193
+
-[Automatically load the solution when opening a Git repository](#automatically-load-the-solution-when-opening-a-git-repository)
194
+
-[Automatically check out branches with double-click or the Enter key](#automatically-check-out-branches-with-double-click-or-the-enter-key)
195
+
196
+
:::moniker-end
171
197
172
198
### Default location
173
199
174
200
**Default location** configures the default folder in which repositories are cloned.
175
201
176
202
:::image type="content" source="media/default-location-setting.png" alt-text="Screenshot showing the default location field in the Options dialog box.":::
177
203
204
+
:::moniker range=">=vs-2022"
205
+
### Default branch name
206
+
207
+
The **Default branch name** setting configures the default branch for new repos that you create locally. If you leave it blank, the default for your locally installed Git is used.
208
+
209
+
:::image type="content" source="media/vs-2022/default-branch-name.png" alt-text="Screenshot showing the default branch name field in the Options dialog box.":::
210
+
211
+
This setting is available in Visual Studio 17.14 and later.
212
+
213
+
:::moniker-end
214
+
178
215
### Close open solutions not under Git when opening a repository
179
216
180
-
By default, Visual Studio closes any open solution or folder when you switch to another repository. When it does so, it might also load the solution or folder of the new repository based on if you choose to [Open folder in Solution Explorer when opening a Git repository](#open-folder-in-solution-explorer-when-opening-a-git-repository) and [Automatically load the solution when opening a Git repository](#automatically-load-the-solution-when-opening-a-git-repository). This maintains the consistency between the open code and open repository. However, if your solution is not in the same folder root as your repository, you may want to keep the solution open when you switch to its repository. You can do that with this setting. The values are, as follows:
217
+
By default, Visual Studio closes any open solution or folder when you switch to another repository. When it does so, it might also load the solution or folder of the new repository based on if you choose to [Open folder in Solution Explorer when opening a Git repository](#open-folder-in-solution-explorer-when-opening-a-git-repository) and [Automatically load the solution when opening a Git repository](#automatically-load-the-solution-when-opening-a-git-repository). This setting maintains the consistency between the open code and open repository. However, if your solution is not in the same folder root as your repository, you may want to keep the solution open when you switch to its repository. You can do that with this setting. The values are, as follows:
181
218
182
219
-**Yes**: When a repository is opened, the currently open solution is always closed
183
220
-**No**: When a repository is opened, Visual Studio performs a check as to whether the current solution is under Git. If it is not, then the solution remains open.
184
221
-**Always ask** (default): When this is set, you can make a choice through a dialog box per repository open, whether you want to keep the current solution open or close it.
185
222
186
223
:::image type="content" source="media/close-sln-setting.png" alt-text="Screenshot showing the close solution setting in the Options dialog box.":::
187
224
225
+
:::moniker range=">=vs-2022"
226
+
227
+
### Automatically activate multiple repositories
228
+
229
+
This setting lets you control whether Visual Studio spends resources on activating multiple repositories at once, or whether to optimize your workflow by only activating a single repository at a time. If you primarily work with a single repository, you can turn off this setting to improve the performance of Visual Studio. If you change the setting, the change doesn't take effect until the next time the solution is loaded.
230
+
231
+
-**Yes** (default): Visual Studio activates multiple repositories.
232
+
-**No**: Visual Studio only activates one repository.
233
+
234
+
:::image type="content" source="media/vs-2022/git-settings-automatically-activate-multiple-repos.png" alt-text="Screenshot showing the Automatically activate multiple repositories setting in the Options dialog box.":::
235
+
236
+
See [Work with multiple repos](git-multi-repository-support.md).
237
+
:::moniker-end
238
+
188
239
### Enable download of author images from third-party sources
189
240
190
241
Enable download of author images from third-party sources is a Visual Studio-specific setting at global scope. When checked, author images are downloaded from the [Gravatar image service](https://en.gravatar.com/), if available, and displayed in the commit and history views.
191
242
192
243
:::image type="content" source="media/download-image-setting.png" alt-text="Screenshot showing checkbox to enable download of author images from third-party source in the Options dialog box. ":::
193
244
194
245
>[!IMPORTANT]
195
-
>In order to provide author images in the Commit and History views, the tool creates an MD5 hash for the author email addresses stored in the active repository. This hash is then sent to Gravatar to find a matching hash value for users that have previously signed up for the service. If a match is found, the user image will be retrieved from the service and displayed in Visual Studio. Users that have not configured the service will return a randomly generated image. Note, email addresses are not recorded by Visual Studio, nor are they ever shared with Gravatar or any other third party.
246
+
>In order to provide author images in the Commit and History views, the tool creates an MD5 hash for the author email addresses stored in the active repository. This hash is then sent to Gravatar to find a matching hash value for users that have previously signed up for the service. If a match is found, the user image is retrieved from the service and displayed in Visual Studio. Users that have not configured the service return a randomly generated image. Note, email addresses are not recorded by Visual Studio, nor are they ever shared with Gravatar or any other third party.
196
247
197
248
### Commit changes after merge by default
198
249
@@ -215,22 +266,34 @@ For more information, see [push --force-with-lease](https://git-scm.com/docs/git
215
266
216
267
### Open folder in Solution Explorer when opening a Git repository
217
268
218
-
When you use Visual Studio to open or switch to a Git repository, Visual Studio loads the Git content so that you can view changes, commits, branches, and manage your repository from within the IDE. In addition, Visual Studio will also load the code of the repository in Solution Explorer. Visual Studio will scan the repository folder for solutions, CMakeLists.txt, or any other view files that it recognizes and display them as a list in Solution Explorer. From there, you can select a solution to load or the folder to view the directory contents. When you turn off this checkbox, then Visual Studio will not open the repository folder in Solution Explorer. This will essentially allow you to open Visual Studio as a Git repository manager only. This setting is on by default.
269
+
When you use Visual Studio to open or switch to a Git repository, Visual Studio loads the Git content so that you can view changes, commits, branches, and manage your repository from within the IDE. In addition, Visual Studio also loads the code of the repository in Solution Explorer. Visual Studio scans the repository folder for solutions, CMakeLists.txt, or any other view files that it recognizes and display them as a list in Solution Explorer. From there, you can select a solution to load or the folder to view the directory contents. When you turn off this checkbox, then Visual Studio doesn't open the repository folder in Solution Explorer. This option essentially allows you to open Visual Studio as a Git repository manager only. The setting is on by default.
219
270
220
271
:::image type="content" source="media/open-folder-setting.png" alt-text="Screenshot showing the checkbox to open folder when opening a Git repository in the Options dialog box.":::
221
272
222
273
### Automatically load the solution when opening a Git repository
223
274
224
-
This setting is applicable only when the [Open folder in Solution Explorer when opening a Git repository](#open-folder-in-solution-explorer-when-opening-a-git-repository) setting is turned on. When you open a Git repository in Visual Studio, and the subsequent folder scan detects there is only one solution present in your repository, then Visual Studio automatically loads that solution. If you turn off the setting, then the Solution Explorer will display the single solution present in the repository in the list of views. But it will not load the solution. By default, this setting is off.
275
+
This setting is applicable only when the [Open folder in Solution Explorer when opening a Git repository](#open-folder-in-solution-explorer-when-opening-a-git-repository) setting is turned on. When you open a Git repository in Visual Studio, and the subsequent folder scan detects there is only one solution present in your repository, then Visual Studio automatically loads that solution. If you turn off the setting, then the Solution Explorer displays the single solution present in the repository in the list of views. But it doesn't load the solution. By default, this setting is off.
225
276
226
277
:::image type="content" source="media/load-solution-setting.png" alt-text="Screenshot showing the checkbox to automatically load the solution when opening a Git repository in the Options dialog box.":::
227
278
228
279
### Automatically check out branches with double-click or the Enter key
229
280
230
-
The Git Repository window has a list of branches displayed in a tree structure. Single selecting a branch will switch the commit history pane to display the commits for the selected branch. To check out a branch, you can right-click to open the context menu and select **Checkout**. If you turn on this setting, then double-clicking or pressing the Enter key will check out the branch and display its commits.
281
+
The **Git Repository** window has a list of branches displayed in a tree structure. Single selecting a branch switches the commit history pane to display the commits for the selected branch. To check out a branch, you can right-click to open the context menu and select **Checkout**. If you turn on this setting, then double-clicking or pressing the Enter key checks out the branch and display its commits.
231
282
232
283
:::image type="content" source="media/checkout-branch-setting.png" alt-text="Screenshot showing the checkbox to check out branches with double-click or Enter key in the Options dialog box.":::
233
284
285
+
:::moniker range=">=vs-2022"
286
+
### Restore the Git Repository window on restart
287
+
288
+
If checked, the **Git Repository** window will open along with other permanent windows when you start the Visual Studio IDE, if the window was open when Visual Studio was last closed. The position of the window is saved in the window layout, so if you had moved the window or docked it, it opens just where you had it before. Clear the checkbox to prevent the window from opening when Visual Studio starts. You can still open the window manually by using the **View**, **Git Repository** menu command, by pressing **Ctrl**+**0**, **Ctrl**+**R**, or by pressing **Ctrl**+**Q** and searching on **Git Repository**.
289
+
290
+
If you use this window regularly, it can be very convenient to open it automatically when you start the IDE. However, opening and populating the window on startup can use a lot of computing resources, so if you're not actively using it, it's more efficient to disable this behavior.
291
+
292
+
:::image type="content" source="./media/vs-2022/git-settings-restore-the-git-repository-window.png" alt-text="Screenshot showing the Restore Git Repository window setting in the Options dialog box.":::
293
+
294
+
This setting is available in Visual Studio 17.14 and later. For more information, see [Browse a repository](./git-browse-repository.md).
0 commit comments