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
To use the Visual Studio client tools you’ll need to install Visual Studio 2012, apply Visual Studio 2012 Update 2, and finally install Visual Studio Tools for Git. If you want to use Team Foundation Service, you can sign up for free.
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.)
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.
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.
Attributes File: To specify options such as how the system handles line-breaks, you can specify a .gitattributes file. See Customizing Git – Git Attributes.
Edit the .gitattributes file
and look for this:
and if you find it, replace it with this:
(The first instruction normalizes line endings to CRLF in your working copy of the file when you modify it. We’ve determined that this isn’t the recommended approach by the community. We recommend you use the second instruction instead.)
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.