在Linux / Ubuntu上的Subversion中提交已更改的文件,添加新文件并省略一些文件到外部服务器

时间:2023-01-26 15:15:36

I am running Subversion on Ubuntu. I have checked out the files for a project from an external server, done some changes on the files plus added some new files. Now I want to commit all the changes and the new files. However I modified the database configuration file to function with my local server so I don't want to commit that change as it will mess things up. Because I made a lot of changes and added many new files I don't want to commit the files one by one.

我在Ubuntu上运行Subversion。我从外部服务器检查了项目的文件,对文件进行了一些更改,并添加了一些新文件。现在我想提交所有更改和新文件。但是我修改了数据库配置文件以使用我的本地服务器,因此我不想提交更改,因为它会搞砸。因为我做了很多更改并添加了许多新文件,所以我不想逐个提交文件。

4 个解决方案

#1


So you have two problems, one, that you want to ignore a file that you've changed and two, that you want to add a bunch of files to subversion at once.

所以你有两个问题,一个是你要忽略一个你已经改变的文件,两个是你想要一次性地将一堆文件添加到subversion中。

To solve the first problem you should use the previous suggestion of:

要解决第一个问题,您应该使用之前的建议:

svn propedit svn:ignore <dir>

svn propedit svn:忽略

and enter the name of the file into the editor that comes up (depending on the $EDITOR environment variable, this will most likely be emacs, vi, or nano by default). Make sure to save your changes to this file or it won't help.

并在出现的编辑器中输入文件的名称(取决于$ EDITOR环境变量,默认情况下很可能是emacs,vi或nano)。确保将更改保存到此文件,否则无效。

To solve the second problem, just loop over the files in your working copy via svn add in a bash equivalent terminal emulator - it won't add something that's already under version control and you can safely ignore the warnings it gives you. The better solution would be to write a quick script to check if something is in svn first and only add it if it's not, but I think for what you're doing it might be a waste of time. So, just:

要解决第二个问题,只需通过svn add在bash等效的终端模拟器中循环工作副本中的文件 - 它不会添加已经受版本控制的东西,你可以放心地忽略它给你的警告。更好的解决方案是编写一个快速脚本来检查svn中是否存在某些内容,如果不是,则只添加它,但我认为你正在做的事情可能是浪费时间。所以就:

svn add *

svn添加*

from the root directory of your project and then, after checking svn status to make sure you're happy with the changes, svn commit. The commit command will find all your changes (minus the ones in svn:ignore) and send them off to your repository.

从项目的根目录开始,然后在检查svn状态后确保对更改感到满意,svn commit。 commit命令将查找所有更改(减去svn:ignore中的更改)并将其发送到存储库。

#2


What you should do is create a copy of the database configuration file, and load that instead. Basically, leave a canonical "standard" db config file in the repo, and have a localized config file that's based off the standard. Then set svn:ignore on your local copy so it doesn't get committed.

您应该做的是创建数据库配置文件的副本,然后加载它。基本上,在repo中保留规范的“标准”db配置文件,并且具有基于标准的本地化配置文件。然后在本地副本上设置svn:ignore,这样就不会提交。

#3


Use svn:ignore property to mark the files you do not want to version control.

使用svn:ignore属性标记您不想进行版本控制的文件。

#4


If you have not already added the new files to subversion you will need to mark them as added first by executing the "svn add " command.

如果尚未将新文件添加到subversion,则需要先执行“svn add”命令将它们标记为已添加。

When you commit you can specify the files that you want to commit. You can use the shell features (glob matching, etc.) to specify multiple files that match certain patterns. There is no need to commit each file individually.

提交时,您可以指定要提交的文件。您可以使用shell功能(glob匹配等)指定与特定模式匹配的多个文件。无需单独提交每个文件。

#1


So you have two problems, one, that you want to ignore a file that you've changed and two, that you want to add a bunch of files to subversion at once.

所以你有两个问题,一个是你要忽略一个你已经改变的文件,两个是你想要一次性地将一堆文件添加到subversion中。

To solve the first problem you should use the previous suggestion of:

要解决第一个问题,您应该使用之前的建议:

svn propedit svn:ignore <dir>

svn propedit svn:忽略

and enter the name of the file into the editor that comes up (depending on the $EDITOR environment variable, this will most likely be emacs, vi, or nano by default). Make sure to save your changes to this file or it won't help.

并在出现的编辑器中输入文件的名称(取决于$ EDITOR环境变量,默认情况下很可能是emacs,vi或nano)。确保将更改保存到此文件,否则无效。

To solve the second problem, just loop over the files in your working copy via svn add in a bash equivalent terminal emulator - it won't add something that's already under version control and you can safely ignore the warnings it gives you. The better solution would be to write a quick script to check if something is in svn first and only add it if it's not, but I think for what you're doing it might be a waste of time. So, just:

要解决第二个问题,只需通过svn add在bash等效的终端模拟器中循环工作副本中的文件 - 它不会添加已经受版本控制的东西,你可以放心地忽略它给你的警告。更好的解决方案是编写一个快速脚本来检查svn中是否存在某些内容,如果不是,则只添加它,但我认为你正在做的事情可能是浪费时间。所以就:

svn add *

svn添加*

from the root directory of your project and then, after checking svn status to make sure you're happy with the changes, svn commit. The commit command will find all your changes (minus the ones in svn:ignore) and send them off to your repository.

从项目的根目录开始,然后在检查svn状态后确保对更改感到满意,svn commit。 commit命令将查找所有更改(减去svn:ignore中的更改)并将其发送到存储库。

#2


What you should do is create a copy of the database configuration file, and load that instead. Basically, leave a canonical "standard" db config file in the repo, and have a localized config file that's based off the standard. Then set svn:ignore on your local copy so it doesn't get committed.

您应该做的是创建数据库配置文件的副本,然后加载它。基本上,在repo中保留规范的“标准”db配置文件,并且具有基于标准的本地化配置文件。然后在本地副本上设置svn:ignore,这样就不会提交。

#3


Use svn:ignore property to mark the files you do not want to version control.

使用svn:ignore属性标记您不想进行版本控制的文件。

#4


If you have not already added the new files to subversion you will need to mark them as added first by executing the "svn add " command.

如果尚未将新文件添加到subversion,则需要先执行“svn add”命令将它们标记为已添加。

When you commit you can specify the files that you want to commit. You can use the shell features (glob matching, etc.) to specify multiple files that match certain patterns. There is no need to commit each file individually.

提交时,您可以指定要提交的文件。您可以使用shell功能(glob匹配等)指定与特定模式匹配的多个文件。无需单独提交每个文件。