Skip to content

Commit f229118

Browse files
ghogenjumattosaamarsh
authored
Update Git settings (#13900)
* 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]>
1 parent 689e400 commit f229118

File tree

5 files changed

+72
-9
lines changed

5 files changed

+72
-9
lines changed

docs/version-control/git-settings.md

Lines changed: 72 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Git settings in Visual Studio
33
titleSuffix: ""
44
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
66
ms.topic: conceptual
77
author: ghogen
88
ms.author: ghogen
@@ -23,7 +23,13 @@ You can configure two types of settings:
2323

2424
1. To configure Git settings in Visual Studio, choose **Settings** from the top-level Git menu.
2525

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"
2631
:::image type="content" source="media/git-menu-settings.png" alt-text="The Git menu with a callout to the Settings command.":::
32+
:::moniker-end
2733

2834
2. Choose **Git Global Settings** or **Git Repository Settings** to view and configure global-level or repository-level settings.
2935

@@ -52,7 +58,7 @@ You can also configure and check some of the most common Git configuration setti
5258
5359
### Name and email
5460

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.
5662

5763
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**.
5864

@@ -120,7 +126,7 @@ Here's how to change the settings:
120126

121127
### Credential helper
122128

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:
124130

125131
- **GCM for Windows**: Use [Git Credential Manager for Windows](https://github.com/microsoft/Git-Credential-Manager-for-Windows) as the helper.
126132
- **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:
136142

137143
### Diff & merge tools
138144

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.
140146

141147
:::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.":::
142148

@@ -160,39 +166,84 @@ To view all of your other Git configuration settings, you can open and view the
160166

161167
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.
162168

169+
:::moniker range=">=vs-2022"
170+
163171
- [Default location](#default-location)
172+
- [Default branch name](#default-branch-name)
164173
- [Close open solutions not under Git when opening a repository](#close-open-solutions-not-under-git-when-opening-a-repository)
174+
- [Automatically activate multiple repositories](#automatically-activate-multiple-repositories)
165175
- [Enable download of author images from third-party sources](#enable-download-of-author-images-from-third-party-sources)
166176
- [Commit changes after merge by default](#commit-changes-after-merge-by-default)
167177
- [Enable push --force](#enable-push---force-with-lease)
168178
- [Open folder in Solution Explorer when opening a Git repository](#open-folder-in-solution-explorer-when-opening-a-git-repository)
169179
- [Automatically load the solution when opening a Git repository](#automatically-load-the-solution-when-opening-a-git-repository)
170180
- [Automatically check out branches with double-click or the Enter key](#automatically-check-out-branches-with-double-click-or-the-enter-key)
181+
- [Restore the Git Repository window on restart](#restore-the-git-repository-window-on-restart)
182+
183+
:::moniker-end
184+
185+
:::moniker range="<=vs-2019"
186+
187+
- [Default location](#default-location)
188+
- [Close open solutions not under Git when opening a repository](#close-open-solutions-not-under-git-when-opening-a-repository)
189+
- [Enable download of author images from third-party sources](#enable-download-of-author-images-from-third-party-sources)
190+
- [Commit changes after merge by default](#commit-changes-after-merge-by-default)
191+
- [Enable push --force](#enable-push---force-with-lease)
192+
- [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
171197

172198
### Default location
173199

174200
**Default location** configures the default folder in which repositories are cloned.
175201

176202
:::image type="content" source="media/default-location-setting.png" alt-text="Screenshot showing the default location field in the Options dialog box.":::
177203

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+
178215
### Close open solutions not under Git when opening a repository
179216

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:
181218

182219
- **Yes**: When a repository is opened, the currently open solution is always closed
183220
- **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.
184221
- **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.
185222

186223
:::image type="content" source="media/close-sln-setting.png" alt-text="Screenshot showing the close solution setting in the Options dialog box.":::
187224

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+
188239
### Enable download of author images from third-party sources
189240

190241
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.
191242

192243
:::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. ":::
193244

194245
>[!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.
196247
197248
### Commit changes after merge by default
198249

@@ -215,22 +266,34 @@ For more information, see [push --force-with-lease](https://git-scm.com/docs/git
215266

216267
### Open folder in Solution Explorer when opening a Git repository
217268

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.
219270

220271
:::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.":::
221272

222273
### Automatically load the solution when opening a Git repository
223274

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.
225276

226277
:::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.":::
227278

228279
### Automatically check out branches with double-click or the Enter key
229280

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.
231282

232283
:::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.":::
233284

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).
295+
:::moniker-end
296+
234297
## Related content
235298

236299
> [!IMPORTANT]
37.5 KB
Loading
80.3 KB
Loading
19.4 KB
Loading
28.4 KB
Loading

0 commit comments

Comments
 (0)