Customize Git settings in Visual Studio

Customize Git settings in Visual Studio

Rate This
  • Comments 1

By: Andy Lewis and Matthew Mitrik

Today we're here to help you:

  • Specify how you identify yourself on the changes you commit
  • Specify the default location for Git repositories
  • Use images (from either TFS or Gravatar) to identify authors of commits
  • Use a .gitignore file to block clutter from entering your user experience and your repository
  • Use the .gitattributes file to make sure changes are correctly recognized by the system
  • Modify Git settings from the command prompt

Got the latest version of Visual Studio with Git? If not, click here.

You can specify three kinds of Git settings, listed in order of supersedence:

  • Repository settings apply to the work done in the local repository.
  • Global settings apply to the work done by the current user on the dev machine.
  • System settings apply to all work done on the client dev machine. (Visual Studio respects these settings, but does not expose them.)

For more details on Git settings, see Customizing Git - Git Configuration and git-config command.

Go to the page where you can tune your settings

Apply global dev machine settings

Global settings are scoped to each user on the client dev machine. So for example if you share a dev machine with Julia, then you and she can each have different settings.

User Name and Email Address: Git associates each commit you create with your name and email address. When you first begin using Visual Studio with Git on your dev machine, if you begin by cloning from a Git team project, then Visual Studio fills these in for you.

Default Repository Location: You can specify the default root directory where you want to create or clone new local Git repositories.

Author images: You can use images to more easily see the author of each commit.

  • If your Git repo remote origin is in a TFS Git team project, team members can specify their images in their TFS profiles. How?

  • If your Git repo remote origin is in a third-party Git service (such GitHub, Bitbucket, or CodePlex), select Enable download of author images from 3rd party source, and then ask team members to set up Gravatar accounts for their email addresses.

Note: Enable download of author images from 3rd party source also works for TFS Git team projects in cases where the author has not supplied a profile image.

An example of how author images enhance the collaborative experience:

Apply repository settings

Before you can modify Git repository settings, you must have a local Git repo opened in Team Explorer. See Create, connect, and publish using Visual Studio with Git.

Repository settings are scoped to each local Git repository on the dev machine. Typically you want to commit these files so that everyone else on your team uses the same repository settings on their dev machines.

Ignore File: To avoid checking in temporary non-source items such as binaries, you can specify a .gitignore file. See Ignoring files and gitignore(5) Manual Page.

Attributes File: To specify options such as how the system handles line-breaks, you can specify a .gitattributes file. See Customizing Git - Git Attributes.

Did you create your Git repo using Visual Studio 2012 QU2 CTP3 or earlier?

Tip: If your repository does not have these files, you really should use Visual Studio to add some default files that apply the most typically useful settings. Doing so will avoid distraction and potential clutter in your repo from non-source files such as locally-built binaries.

Commit your settings file changes

After you make changes to your repository settings files, you should commit them.

Modify Git settings from the command prompt

You can modify all Git settings from the command prompt using the git-config command.

If you have not already done so, install the Git command-prompt tools.

Open the command prompt.

Enter the command. For info on the commands you can use, see Customizing Git - Git Configuration and git-config command.

Leave a Comment
  • Please add 1 and 6 and type the answer here:
  • Post
  • Where is the global .gitconfig located?  For me it's not using the same one as Git4Windows (%userprofile%/.gitconfig) by default.

Page 1 of 1 (1 items)