什么是版本控制?What is version control?

作者: Robert OutlawBy: Robert Outlaw

版本控制系统是一种软件,可帮助你跟踪你在代码中所做的更改。Version control systems are software that help you track changes you make in your code over time. 编辑代码时,通知版本控制系统生成文件的快照。As you edit to your code, you tell the version control system to take a snapshot of your files. 版本控制系统会永久保存此文件快照,以便用户稍后能够根据需要进行查阅。The version control system saves that snapshot permanently so you can recall it later if you need it.

如果没有版本控制,则需要在计算机上保留代码的多个副本。Without version control, you’re tempted to keep multiple copies of code on your computer. 这是很危险的,很容易在错误的代码副本中更改或删除文件,这可能会丢失工作。This is dangerous-it’s easy to change or delete a file in the wrong copy of code, potentially losing work. 版本控制系统通过管理代码的所有版本来解决此问题,但一次提供单个版本。Version control systems solve this problem by managing all versions of your code but presenting you with a single version at a time.

版本控制的优点Benefits of version control

承载多个用户的服务器
创建工作流Create workflows
版本控制工作流通过不同和不兼容的工具,防止任何人使用自己的开发过程。Version control workflows prevent the chaos of everyone using their own development process with different and incompatible tools. 版本控制系统提供了进程强制执行和权限,因此每个人都保持在同一页面上。Version control systems provide process enforcement and permissions so everyone stays on the same page.
承载多个用户的服务器
使用版本Work with versions
每个版本都提供了版本中的更改的说明,例如修复 bug 或添加功能。Every version has a description for what the changes in the version do, such as fix a bug or add a feature. 这些说明有助于按版本而不是单个文件更改跟踪代码中的更改。These descriptions help you follow changes in your code by version instead of by individual file changes. 可以根据需要随时从版本控制查看和还原存储在版本中的代码。Code stored in versions can be viewed and restored from version control at any time as needed. 这样,就可以轻松地将新工作基于任何版本的代码。This makes it easy to base new work off any version of code.
承载多个用户的服务器
将代码组合在一起Code Together
版本控制同步版本,并确保您的更改不会与团队中的其他更改发生冲突。Version control synchronizes versions and makes sure that your changes don’t conflict with other changes from your team. 你的团队依赖版本控制来帮助解决和避免冲突,即使用户同时进行更改也是如此。Your team relies on version control to help resolve and prevent conflicts, even when people make changes at the same time.
承载多个用户的服务器
保留历史记录Keep a history
当你的团队保存代码的新版本时,版本控制会保留更改的历史记录。Version control keeps a history of changes as your team saves new versions of your code. 可以查看此历史记录以找出进行更改的人员、原因和时间。This history can be reviewed to find out who, why, and when changes were made. 历史记录使你可以放心地进行试验,因为你可以随时回滚到以前的正常版本。History gives you the confidence to experiment since you can roll back to a previous good version at any time. 通过历史记录,你可以从任何版本的代码(如)中进行工作以修复以前版本中的 bug。History lets you base work from any version of code, such as to fix a bug in a previous release.
承载多个用户的服务器
自动执行任务Automate tasks
版本控制自动化功能节省了团队时间并生成一致的结果。Version control automation features save your team time and generate consistent results. 在将新版本保存到版本控制时自动执行测试、代码分析和部署。Automate testing, code analysis , and deployment when new versions are saved to version control.

版本控制为何重要Why version control matters

有很多东西需要花费大量时间作为开发人员重现 bug,学习新工具,并添加新功能或内容。There are plenty of things that can take up your time as a developer-reproducing bugs, learning new tools, and adding new features or content. 随着用户的需求扩大,版本控制可帮助你的团队协同工作并按时发货。As the demands of your users scale up, version control helps your team work together and ship on time.

使用 Team Services Git 教程,开始将版本控制与你喜欢的工具配合使用。Get started using version control with your favorite tools with the Team Services Git tutorial.

了解 Azure Repos中的 git 无限制免费专用 Git 存储库。Learn Git Get started with unlimited free private Git repos in Azure Repos.

Image: Robert Outlaw,MSFT Robert 是 Microsoft 在 Azure DevOps 和 Team Foundation Server 工作的内容开发人员。Robert is a content developer at Microsoft working on Azure DevOps and Team Foundation Server.