你如何“检查”代码?

时间:2022-03-30 07:32:50

I've never really worked with a lot of people where we had to check out code and have repositories of old code, etc. I'm not sure I even know what these terms mean. If I want to to start a new project that involves more than myself that tracks all the code changes, does "check out" (again, don't know what that means), how do I get started? Is that what SVN is for? Something else? Do I download a program that keeps up with the code?

我从来没有真正与很多人合作,我们不得不检查代码并拥有旧代码的存储库等。我不确定我甚至不知道这些术语的含义。如果我想创建一个涉及跟踪所有代码更改的新项目,那么“检查”(再次,不知道这意味着什么),我该如何开始?那是SVN的用途吗?别的什么?我是否下载了一个跟上代码的程序?

What do I do?

我该怎么办?

It will all be in house. No Internet for storing code.

它将全部在内部。没有用于存储代码的Internet。

I don't even know if what I am asking for is called source control. I see things about checking out, SVN, source control, and so on. I don't know if it is all talking about the same thing or not. I was hoping to use something open source.

我甚至不知道我要求的是源控制。我看到了关于签出,SVN,源代码控制等的事情。我不知道是不是所有人都在谈论同样的事情。我希望用一些开源的东西。

5 个解决方案

#1


So, a long time ago, in the bad old days of yore, source control used a library metaphor. If you wanted to edit a file, the only way to avoid conflicts was to make sure that you were the ONLY one editing the file. What you'd do is ask the source control system to "check out" that file, indicating that you were editing it and nobody else was allowed to edit it until you made your changes and the file was "checked in". If you needed to make a change to a checked out file, you had to go find that freakin' developer who'd had everythingImportant.conf checked out since last Tuesday..freakin' Bill...

所以,很久以前,在昔日的糟糕旧时代,源代码控制使用了一个图书馆的比喻。如果您想编辑文件,避免冲突的唯一方法是确保您是唯一一个编辑文件的人。您要做的是要求源控制系统“检出”该文件,表明您正在编辑它,并且在您进行更改并且文件已“签入”之前,没有其他人可以编辑它。如果你需要对已检出的文件进行更改,你必须找到那个自上周二以来已经检查过的所有missImportant.conf的开发人员.freakin'Bill ......

Anyway, source control doesn't really work like that anymore, but the language stuck with us. Nowadays, "checking out" code means downloading a copy of the code from the code repository. The files will appear in a local directory, allowing you to use them, compile the code, and even make changes to the source that you could perhaps upload back to the repository later, should you need to. Even better, with just a single command, you can get all the changes that have been made by other developers since the last time you downloaded the code. Good stuff.

无论如何,源代码控制实际上并不像那样,但是语言一直困扰着我们。如今,“签出”代码意味着从代码库下载代码的副本。这些文件将出现在本地目录中,允许您使用它们,编译代码,甚至可以根据需要更改您可能稍后上传回存储库的源代码。更好的是,只需一个命令,您就可以获得自上次下载代码以来其他开发人员所做的所有更改。好东西。

There are several major source control libraries, of which SVN (also called Subversion) is one (CVS, Git, HG, Perforce, ClearCase, etc are others). I recommend starting with SVN, Git, or HG, since they're all free and all have excellent documentation.

有几个主要的源控制库,其中SVN(也称为Subversion)是一个(CVS,Git,HG,Perforce,ClearCase等等)。我建议从SVN,Git或HG开始,因为它们都是免费的,并且都有很好的文档。

You might want to start using source control even if you're the only developer. There's nothing worse than realizing that last night the thousand lines of code you deleted as useless were actually critically important and are now lost forever. Source control allows you to zoom forwards and backwards in the history of your files, letting you easily recover stuff that you should not have removed, and giving you a lot more confidence about deleting useless stuff. Plus, fiddling around with it on your own is good practice.

即使您是唯一的开发人员,您也可能希望开始使用源代码管理。没有什么比认识到昨晚你删除的无用的千行代码实际上至关重要并且现在永远丢失的更糟糕的事情。源代码控制允许您在文件的历史记录中向前和向后缩放,让您轻松恢复不应删除的内容,并让您更有信心删除无用的内容。另外,自己摆弄它是很好的做法。

Being comfortable with source/revision control software is a critical job skill of any serious software engineer. Mastering it will effectively level you up as a professional developer. Coming onto a project and finding that the team keeps all their source in a folder somewhere is an awful experience. Good luck! You're already on the right path just by being interested!

熟悉源/版本控制软件是任何认真的软件工程师的关键工作技能。掌握它将有效地使您成为一名专业开发人员。进入一个项目并发现团队将所有源代码保存在某个文件夹中是一种糟糕的体验。祝好运!只是感兴趣,你已经走在了正确的道路上!

#2


Check out Eric Sink's excellent series of articles:

查看Eric Sink的优秀系列文章:

Source Control HOWTO

源控制HOWTO

#3


I recommend Git and Subversion (SVN) both as free, open-source version control systems that work very well. Git has some nice features given that it can be easier to work decentralized.

我推荐Git和Subversion(SVN)作为免费的开源版本控制系统,它们运行良好。 Git有一些很好的功能,因为它可以更容易分散工作。

#4


Checkout means retrieving a file from a source control system. A source control system is a database (some, like CVS, use just specially marked up text files, but a file system is also a database) that holds all versions of your code (that are checked in after you make modifications).

Checkout表示从源控制系统检索文件。源控制系统是一个数据库(有些像CVS一样,只使用特别标记的文本文件,但文件系统也是一个数据库),它包含所有版本的代码(在您进行修改后签入)。

Microsoft Visual SourceSafe uses a very proprietary database which is prone to corruption if it is not regularly maintained and uses reserved checkouts exclusively. Don't use it, for all those reasons.

Microsoft Visual SourceSafe使用非常专有的数据库,如果不经常维护并且仅使用保留的签出,则该数据库容易出现损坏。出于所有这些原因,不要使用它。

The difference between a reserved checkout and an unreserved checkout is in an unreserved checkout; two people can be modifying the same file at once. The first one to check in gets in no problem, and the second one has to update their code to the latest version and merge the changes into theirs (which usually happens automatically, but if the same area of the file was changed, then there is a conflict, which has to be resolved before it can be checked in).

保留结账和未保留结账之间的区别在于无保留结账;两个人可以一次修改同一个文件。第一个签入没有问题,第二个必须更新他们的代码到最新版本并将更改合并到他们的(这通常会自动发生,但如果文件的相同区域被更改,那么有冲突,必须先解决才能办理登机手续)。

For some arguments for unreserved checkouts, see here.

有关无保留结账的一些论据,请参见此处。

Following this, you will be looking at a build process that independently checks out the code and builds the source code, so that everyone's changes are built and distributed together.

在此之后,您将看到一个构建过程,该过程独立地检查代码并构建源代码,以便每个人的更改都是一起构建和分发的。

#5


Are you creating the project that requires source control? If so, choose a source control system that meets your needs, and read the documentation for how to get it set up. If you are simply using a previously set up source control system for an existing project, ask a coworker who has been using it, or ask the person who set up the source control system.

您是否正在创建需要源代码管理的项目?如果是这样,请选择满足您需求的源控制系统,并阅读文档以了解如何设置它。如果您只是为现有项目使用先前设置的源控制系统,请询问已使用它的同事,或询问设置源控制系统的人员。

For choosing a source control system that meets your needs, most source control systems have extensive descriptions of their features online, many provide evaluation or even completely free products, and there are many many many anecdotal descriptions of what working with each individual source control system is like, which can help.

为了选择满足您需求的源控制系统,大多数源控制系统在线对其功能进行了广泛的描述,许多提供评估甚至是完全免费的产品,并且有许多关于使用每个源控制系统的轶事描述是喜欢,这可以帮助。

Just don't use Microsoft Visual SourceSafe if you value your sanity and your code.

如果您重视您的理智和代码,请不要使用Microsoft Visual SourceSafe。

#1


So, a long time ago, in the bad old days of yore, source control used a library metaphor. If you wanted to edit a file, the only way to avoid conflicts was to make sure that you were the ONLY one editing the file. What you'd do is ask the source control system to "check out" that file, indicating that you were editing it and nobody else was allowed to edit it until you made your changes and the file was "checked in". If you needed to make a change to a checked out file, you had to go find that freakin' developer who'd had everythingImportant.conf checked out since last Tuesday..freakin' Bill...

所以,很久以前,在昔日的糟糕旧时代,源代码控制使用了一个图书馆的比喻。如果您想编辑文件,避免冲突的唯一方法是确保您是唯一一个编辑文件的人。您要做的是要求源控制系统“检出”该文件,表明您正在编辑它,并且在您进行更改并且文件已“签入”之前,没有其他人可以编辑它。如果你需要对已检出的文件进行更改,你必须找到那个自上周二以来已经检查过的所有missImportant.conf的开发人员.freakin'Bill ......

Anyway, source control doesn't really work like that anymore, but the language stuck with us. Nowadays, "checking out" code means downloading a copy of the code from the code repository. The files will appear in a local directory, allowing you to use them, compile the code, and even make changes to the source that you could perhaps upload back to the repository later, should you need to. Even better, with just a single command, you can get all the changes that have been made by other developers since the last time you downloaded the code. Good stuff.

无论如何,源代码控制实际上并不像那样,但是语言一直困扰着我们。如今,“签出”代码意味着从代码库下载代码的副本。这些文件将出现在本地目录中,允许您使用它们,编译代码,甚至可以根据需要更改您可能稍后上传回存储库的源代码。更好的是,只需一个命令,您就可以获得自上次下载代码以来其他开发人员所做的所有更改。好东西。

There are several major source control libraries, of which SVN (also called Subversion) is one (CVS, Git, HG, Perforce, ClearCase, etc are others). I recommend starting with SVN, Git, or HG, since they're all free and all have excellent documentation.

有几个主要的源控制库,其中SVN(也称为Subversion)是一个(CVS,Git,HG,Perforce,ClearCase等等)。我建议从SVN,Git或HG开始,因为它们都是免费的,并且都有很好的文档。

You might want to start using source control even if you're the only developer. There's nothing worse than realizing that last night the thousand lines of code you deleted as useless were actually critically important and are now lost forever. Source control allows you to zoom forwards and backwards in the history of your files, letting you easily recover stuff that you should not have removed, and giving you a lot more confidence about deleting useless stuff. Plus, fiddling around with it on your own is good practice.

即使您是唯一的开发人员,您也可能希望开始使用源代码管理。没有什么比认识到昨晚你删除的无用的千行代码实际上至关重要并且现在永远丢失的更糟糕的事情。源代码控制允许您在文件的历史记录中向前和向后缩放,让您轻松恢复不应删除的内容,并让您更有信心删除无用的内容。另外,自己摆弄它是很好的做法。

Being comfortable with source/revision control software is a critical job skill of any serious software engineer. Mastering it will effectively level you up as a professional developer. Coming onto a project and finding that the team keeps all their source in a folder somewhere is an awful experience. Good luck! You're already on the right path just by being interested!

熟悉源/版本控制软件是任何认真的软件工程师的关键工作技能。掌握它将有效地使您成为一名专业开发人员。进入一个项目并发现团队将所有源代码保存在某个文件夹中是一种糟糕的体验。祝好运!只是感兴趣,你已经走在了正确的道路上!

#2


Check out Eric Sink's excellent series of articles:

查看Eric Sink的优秀系列文章:

Source Control HOWTO

源控制HOWTO

#3


I recommend Git and Subversion (SVN) both as free, open-source version control systems that work very well. Git has some nice features given that it can be easier to work decentralized.

我推荐Git和Subversion(SVN)作为免费的开源版本控制系统,它们运行良好。 Git有一些很好的功能,因为它可以更容易分散工作。

#4


Checkout means retrieving a file from a source control system. A source control system is a database (some, like CVS, use just specially marked up text files, but a file system is also a database) that holds all versions of your code (that are checked in after you make modifications).

Checkout表示从源控制系统检索文件。源控制系统是一个数据库(有些像CVS一样,只使用特别标记的文本文件,但文件系统也是一个数据库),它包含所有版本的代码(在您进行修改后签入)。

Microsoft Visual SourceSafe uses a very proprietary database which is prone to corruption if it is not regularly maintained and uses reserved checkouts exclusively. Don't use it, for all those reasons.

Microsoft Visual SourceSafe使用非常专有的数据库,如果不经常维护并且仅使用保留的签出,则该数据库容易出现损坏。出于所有这些原因,不要使用它。

The difference between a reserved checkout and an unreserved checkout is in an unreserved checkout; two people can be modifying the same file at once. The first one to check in gets in no problem, and the second one has to update their code to the latest version and merge the changes into theirs (which usually happens automatically, but if the same area of the file was changed, then there is a conflict, which has to be resolved before it can be checked in).

保留结账和未保留结账之间的区别在于无保留结账;两个人可以一次修改同一个文件。第一个签入没有问题,第二个必须更新他们的代码到最新版本并将更改合并到他们的(这通常会自动发生,但如果文件的相同区域被更改,那么有冲突,必须先解决才能办理登机手续)。

For some arguments for unreserved checkouts, see here.

有关无保留结账的一些论据,请参见此处。

Following this, you will be looking at a build process that independently checks out the code and builds the source code, so that everyone's changes are built and distributed together.

在此之后,您将看到一个构建过程,该过程独立地检查代码并构建源代码,以便每个人的更改都是一起构建和分发的。

#5


Are you creating the project that requires source control? If so, choose a source control system that meets your needs, and read the documentation for how to get it set up. If you are simply using a previously set up source control system for an existing project, ask a coworker who has been using it, or ask the person who set up the source control system.

您是否正在创建需要源代码管理的项目?如果是这样,请选择满足您需求的源控制系统,并阅读文档以了解如何设置它。如果您只是为现有项目使用先前设置的源控制系统,请询问已使用它的同事,或询问设置源控制系统的人员。

For choosing a source control system that meets your needs, most source control systems have extensive descriptions of their features online, many provide evaluation or even completely free products, and there are many many many anecdotal descriptions of what working with each individual source control system is like, which can help.

为了选择满足您需求的源控制系统,大多数源控制系统在线对其功能进行了广泛的描述,许多提供评估甚至是完全免费的产品,并且有许多关于使用每个源控制系统的轶事描述是喜欢,这可以帮助。

Just don't use Microsoft Visual SourceSafe if you value your sanity and your code.

如果您重视您的理智和代码,请不要使用Microsoft Visual SourceSafe。