Source control best practices

Source control is a system that helps manage source files that are shared by a team. Using source control, many people can work on the same set of files while minimizing the risk that one person might inadvertently delete the changes that someone else made to a file.

Knowing how source control works and using the following straightforward guidelines can help team members efficiently work on a project together.

  • Use a source control system.

    Using a source control system correctly enhances cooperation, teamwork, and efficiency while minimizing risk.

  • Keep your source files in source control.

    Check in a copy of each source file you need to build your project in source control. Don't check in files that are compiled or generated from source code. For example, if you use an XSL transform to generate 100 HTML files from a single XML file, don't check in the 100 HTML files; just check in the XML and the transform.

  • Make sure that you are working on the latest version of a file.

    Follow the file check-out procedures that your source-control administrator has specified. Those procedures help make sure you have the latest copies of each file, which means you have the latest changes from other members of your team.

    As other people on your team make changes to files in your project source control repository, the copies of those files that you have in your workspace grow "stale"—they no longer include the changes that your team made.

    Because source control automatically assumes that the last checked in version of a file is the newest version, checking in a stale version of a file after somebody else has checked in a newer version creates extra work and increases the risk that you will lose some important modifications to the file.

  • Check out only what you need.

    Check out only the files that you plan to modify. Don't check out an entire folder unless you plan to modify every file in that folder.

  • Check in promptly.

    Don't leave your files checked out any longer than necessary. Check your files in as soon as you are done modifying and testing them. By doing this, you make sure that your teammates have access to the latest versions of the files.

  • Write good check-in comments.

    When something goes wrong, you can use good check-in comments to help identify where it went wrong and how to fix it more quickly. Even if nothing goes wrong, you'll be able to easily see what changes you made and why you made them.

See also


Adding files to source control
Checking files in and out


Using source control

Send feedback about this topic to Microsoft. © 2011 Microsoft Corporation. All rights reserved.