简体   繁体   English

SVN:有没有办法将文件标记为“不提交”?

[英]SVN: Is there a way to mark a file as “do not commit”?

With TortoiseSVN, I can move a file into the ignore-on-commit changelist, so that when I commit a whole tree, changes to that file do not get committed.使用 TortoiseSVN,我可以将文件移动到提交时忽略更改列表中,这样当我提交整个树时,对该文件的更改不会被提交。

Is there a way to do something like that using the svn command-line tool?有没有办法使用 svn 命令行工具来做类似的事情?

EDIT: Thanks for the suggestions to use svn:ignore , but that doesn't do quite what I was looking for.编辑:感谢使用svn:ignore的建议,但这并不能满足我的要求。

svn:ignore affects things like svn add & svn import . svn:ignore影响之类的东西svn addsvn import It gives it a list of filename patterns to ignore.它给了它一个要忽略的文件名模式列表。

I have a file that's already under source control, but I want to make temporary changes to that file that I don't want to be committed later on when I commit the whole source tree.我有一个已经受源代码控制的文件,但我想对该文件进行临时更改,我不想在提交整个源代码树时提交该文件。 I am making a lot of other changes and I could stick a note on my monitor telling me to revert that file before I commit the tree, but it would be nice if svn could automatically skip that file.我正在进行许多其他更改,我可以在显示器上贴上一条注释,告诉我在提交树之前还原该文件,但如果 svn 可以自动跳过该文件,那就太好了。

Subversion does not have a built-in "do not commit" / "ignore on commit" feature, as of February 2016 / version 1.9.从 2016 年 2 月/版本 1.9 开始,Subversion 没有内置的“不提交”/“提交时忽略”功能。 This answer is a non-ideal command-line workaround这个答案是一个非理想的命令行解决方法

As the OP states, TortoiseSVN has a built in changelist, "ignore-on-commit", which is automatically excluded from commits.正如 OP 所述,TortoiseSVN 有一个内置的更改列表,“忽略提交”,它会自动从提交中排除。 The command-line client does not have this, so you need to use multiple changelists to accomplish this same behavior (with caveats) :命令行客户端没有这个,所以你需要使用多个更改列表来完成同样的行为(有警告)

  • one for work you want to commit [work]一份用于您要提交的工作 [工作]
  • one for things you want to ignore [ignore-on-commit]一个你想忽略的事情 [ignore-on-commit]

Since there's precedent with TortoiseSVN, I use "ignore-on-commit" in my examples for the files I don't want to commit.由于 TortoiseSVN 有先例,因此我在示例中对不想提交的文件使用“提交时忽略”。 I'll use "work" for the files I do, but you could pick any name you wanted.对于我所做的文件,我将使用“工作”,但您可以选择任何您想要的名称。

First, add all files to a changelist named "work".首先,将所有文件添加到名为“work”的更改列表中。 This must be run from the root of your working copy:这必须从工作副本的根目录运行:

svn cl work . -R

This will add all files in the working copy recursively to the changelist named "work".这将递归地将工作副本中的所有文件添加到名为“work”的更改列表中。 There is a disadvantage to this - as new files are added to the working copy, you'll need to specifically add the new files or they won't be included.这样做有一个缺点 - 当新文件添加到工作副本时,您需要专门添加新文件,否则它们将不会被包含在内。 Second, if you have to run this again you'll then need to re-add all of your "ignore-on-commit" files again.其次,如果您必须再次运行它,则需要再次重新添加所有“提交时忽略”文件。 Not ideal - you could start maintaining your own 'ignore' list in a file as others have done.不理想 - 您可以开始在文件中维护自己的“忽略”列表,就像其他人所做的那样。

Then, for the files you want to exclude:然后,对于要排除的文件:

svn cl ignore-on-commit path\to\file-to-ignore

Because files can only be in one changelist, running this addition after your previous "work" add will remove the file you want to ignore from the "work" changelist and put it in the "ignore-on-commit" changelist.因为文件只能在一个更改列表中,所以在您之前的“工作”添加之后运行此添加将从“工作”更改列表中删除您要忽略的文件,并将其放入“提交时忽略”更改列表中。

When you're ready to commit your modified files you do wish to commit, you'd then simply add "--cl work" to your commit:当您准备好提交您希望提交的修改后的文件时,您只需将“--cl work”添加到您的提交中:

svn commit --cl work -m "message"

Here's what a simple example looks like on my machine:这是我机器上的一个简单示例:

D:\workspace\trunk>svn cl work . -R
Skipped '.'
Skipped 'src'
Skipped 'src\conf'
A [work] src\conf\db.properties
Skipped 'src\java'
Skipped 'src\java\com'
Skipped 'src\java\com\corp'
Skipped 'src\java\com\corp\sample'
A [work] src\java\com\corp\sample\Main.java
Skipped 'src\java\com\corp\sample\controller'
A [work] src\java\com\corp\sample\controller\Controller.java
Skipped 'src\java\com\corp\sample\model'
A [work] src\java\com\corp\sample\model\Model.java
Skipped 'src\java\com\corp\sample\view'
A [work] src\java\com\corp\sample\view\View.java
Skipped 'src\resource'
A [work] src\resource\icon.ico
Skipped 'src\test'

D:\workspace\trunk>svn cl ignore-on-commit src\conf\db.properties
D [work] src\conf\db.properties
A [ignore-on-commit] src\conf\db.properties

D:\workspace\trunk>svn status

--- Changelist 'work':
        src\java\com\corp\sample\Main.java
        src\java\com\corp\sample\controller\Controller.java
        src\java\com\corp\sample\model\Model.java
M       src\java\com\corp\sample\view\View.java
        src\resource\icon.ico

--- Changelist 'ignore-on-commit':
M       src\conf\db.properties

D:\workspace\trunk>svn commit --cl work -m "fixed refresh issue"
Sending        src\java\com\corp\sample\view\View.java
Transmitting file data .done
Committing transaction...
Committed revision 9.

An alternative would be to simply add every file you wish to commit to a 'work' changelist, and not even maintain an ignore list, but this is a lot of work, too.另一种方法是简单地将您希望提交的每个文件添加到“工作”更改列表中,甚至不维护忽略列表,但这也需要大量工作。 Really, the only simple, ideal solution is if/when this gets implemented in SVN itself.真的,唯一简单、理想的解决方案是是否/何时在 SVN 中实现。 There's a longstanding issue about this in the Subversion issue tracker, SVN-2858 , in the event this changes in the future.有一个在Subversion的问题跟踪这个一个长期问题, SVN-2858 ,在此事件中改变未来。

I've consistently found myself in this situation too: and changelists don't work for me - I want to make a short list of files that I don't want to commit, rather than maintain a massive list of files that I do want to commit!我一直发现自己在这种情况下也:和修改列表不为我工作-我想使文件的短名单,我不想犯,而不是保持文件的大量列表我确实想承诺!

I work on the linux command-line: so my solution is to create a script /usr/bin/svnn (yes, with two 'n's!) as follows:我在 linux 命令行上工作:所以我的解决方案是创建一个脚本 /usr/bin/svnn(是的,有两个 'n's!),如下所示:

#! /bin/bash
DIR=/home/mike/dev/trunk

IGNORE_FILES="\
        foo/pom.xml \
        foo/src/gwt/App.gwt.xml \
        foo/src/main/java/gwt/Common.gwt.xml \
        foo/src/main/resources/context/datasource/local.xml \
        foo/src/main/resources/context/environment/local.xml"

for i in $IGNORE_FILES; do mv $DIR/$i $DIR/"$i"_; done;

svn "$@"

for i in $IGNORE_FILES; do mv $DIR/"$i"_ $DIR/$i; done;

Obviously, this is tailored to my situation - but just change DIR and IGNORE_FILES to suit your dev setup.显然,这是针对我的情况量身定制的 - 但只需更改 DIR 和 IGNORE_FILES 以适合您的开发设置。 Remeber to change the script to executable with:请记住将脚本更改为可执行文件:

sudo chmod +x /usr/bin/svnn

..then you just use "svnn" instead of "svn" to run subversion without fear of checking in local changes to the files on the IGNORE_FILES list. ..那么你只需使用“svnn”而不是“svn”来运行subversion,而不必担心检查IGNORE_FILES列表中文件的本地更改。 I hope this helps!我希望这有帮助!

I don't believe there is a way to ignore a file in the repository.我不相信有办法忽略存储库中的文件。 We often run into this with web.config and other configuration files.我们经常在使用 web.config 和其他配置文件时遇到这种情况。

Although not perfect, the solution I most often see and use is to have .default file and an nant task to create local copies.虽然不完美,但我最常看到和使用的解决方案是使用 .default 文件和 nant 任务来创建本地副本。

For example, in the repo is a file called web.config.default that has default values.例如,在 repo 中有一个名为web.config.default的文件,它具有默认值。 Then create a nant task that will rename all the web.config.default files to web.config that can then be customized to local values.然后创建一个 nant 任务,将所有web.config.default文件重命名为web.config ,然后可以自定义为本地值。 This task should be called when a new working copy is retrieved or a build is run.当检索到新的工作副本或运行构建时,应调用此任务。

You'll also need to ignore the web.config file that is created so that it isn't committed to the repository.您还需要忽略创建的web.config文件,以便它不会提交到存储库。

Check out changelists , which can provide you with an option to filter out files you have changed but do not want to commit.查看更改列表,它可以为您提供一个选项来过滤掉您已更改但不想提交的文件。 SVN will not automatically skip a file unless you tell it to - and the way you tell it that this file is somehow different to other files is to put it in a changelist. SVN 不会自动跳过一个文件,除非你告诉它 - 而你告诉它这个文件与其他文件有某种不同的方式是把它放在一个更改列表中。

It does require more work for you, and you can only apply the changelist to your working copy (obviously, imagine the chaos that could ensue if you could apply a 'never update' property to a revision!).它确实需要您做更多的工作,并且您只能将更改列表应用于您的工作副本(显然,想象一下如果您可以将“永不更新”属性应用于修订版会带来的混乱!)。

I came to this thread looking for a way to make an "atomic" commit of just some files and instead of ignoring some files on commit I went the other way and only commited the files I wanted:我来到这个线程寻找一种方法来对一些文件进行“原子”提交,而不是忽略提交时的一些文件,我走了另一条路,只提交了我想要的文件:

svn ci filename1 filename2

Maybe, it will help someone.也许,它会帮助某人。

Guys I just found a solution.伙计们,我刚刚找到了解决方案。 Given that TortoiseSVN works the way we want, I tried to install it under Linux - which means, running on Wine.鉴于 TortoiseSVN 以我们想要的方式工作,我尝试在 Linux 下安装它 - 这意味着在 Wine 上运行。 Surprisingly it works!令人惊讶的是它有效! All you have to do is:您所要做的就是:

  1. Add files you want to skip commit by running: "svn changelist 'ignore-on-commit' ".通过运行以下命令添加要跳过提交的文件:“svn changelist 'ignore-on-commit'”。
  2. Use TortoiseSVN to commit: "~/.wine/drive_c/Program\\ Files/TortoiseSVN/bin/TortoiseProc.exe /command:commit /path:'使用 TortoiseSVN 提交:"~/.wine/drive_c/Program\\ Files/TortoiseSVN/bin/TortoiseProc.exe /command:commit /path:'
  3. The files excluded will be unchecked for commit by default, while other modified files will be checked.默认情况下,排除的文件将不选中提交,而其他修改的文件将被选中。 This is exactly the same as under Windows.这与在 Windows 下完全相同。 Enjoy!享受!

(The reason why need to exclude files by CLI is because the menu entry for doing that was not found, not sure why. Any way, this works great!) (需要通过 CLI 排除文件的原因是因为找不到执行此操作的菜单项,不知道为什么。无论如何,这很好用!)

Conflicted files are not allowed to be committed.不允许提交冲突的文件。 You can take advantage of this to keep your private changes out of the repository.您可以利用这一点将您的私有更改保留在存储库之外。 This works best with a small number of files.这对少量文件最有效。

To get a conflict for a-file , your working copy (WC) does not have the up to date a-file from the repository, and that the a-file in your WC has changes that are in the same location as changes in the repository (changes that you didn't update to yet).要获得 a a-file的冲突,您的工作副本 (WC) 没有来自存储库的最新a-file ,并且您 WC 中的a-file更改与存储库(您尚未更新的更改)。 If you don't want to wait for the conditions above you can create a conflict for a-file like this:如果您不想等待上述条件,则可以像这样a-file创建冲突:
In working copy 1 (WC1), add a line of text to the top of a-file , such as "make a conflict here" .在工作副本 1 (WC1) 中,在a-file的顶部添加一行文本,例如“make a conflict here” Use the necessary syntax so that you don't break the repository.使用必要的语法,以免破坏存储库。 Commit a-file from WC1.从 WC1 提交a-file In WC2, add a different line of text to the top of a-file , like "i want a conflict" .在 WC2 中,在a-file顶部添加不同的文本行,例如“我想要冲突” Update from WC2, and now a-file should be in conflict.从 WC2 更新,现在一个文件应该有冲突。

Some of the proposed ideas can be implemented like this:一些提议的想法可以这样实现:

On Windows in PowerShell在 PowerShell 中的 Windows 上

add all to default list.ps1全部添加到默认 list.ps1

dir -Recurse | ? { -not $_.PSIsContainer } | % { svn cl default $_.FullName }

add to ignore list.ps1添加到忽略 list.ps1

 dir file1 ... filN  % { $_.FullName } > ignore-on-commit
 cat .\ignore-on-commit | % { svn cl ignore-on-commit $_ }
 svn add ignore-on-commit

Now, you can alias svn ci --changelist default so that you don't have to specify it each time.现在,您可以为svn ci --changelist default别名,这样您就不必每次都指定它。 The additional benefit is that you can store the ignore-on-commit list (if you want) in the repository.另一个好处是您可以将提交时忽略列表(如果需要)存储在存储库中。

I do this for some files which are constantly regenerated but rarely actually changed by hand.我对一些不断重新生成但很少实际手动更改的文件执行此操作。 For instance I add revision number to my config files on specific placeholders so files are changed on each commit, yet manual change is rare.例如,我在特定占位符的配置文件中添加修订号,以便在每次提交时更改文件,但手动更改很少见。

I got tired of waiting for this to get built into SVN.我厌倦了等待它被内置到 SVN 中。 I was using tortoiseSVN with ignore-on-commit, but that pops up a user dialog box that you can't suppress from the command line, and when I run my build script and go and make a cup of tea, I hate it when I come back to discover it's waiting for user input 10% of the way through.我正在使用带有忽略提交的 tortoiseSVN,但这会弹出一个用户对话框,您无法从命令行中抑制该对话框,当我运行我的构建脚本并去泡杯茶时,我讨厌它我回来发现它在等待用户输入 10%。

So here's a windows powershell script that commits only files that aren't in a changelist:所以这里有一个 windows powershell 脚本,它只提交不在更改列表中的文件:

# get list of changed files into targets
[XML]$svnStatus = svn st -q --xml C:\SourceCode\Monad
# select the nodes that aren't in a changelist
$fileList = $svnStatus.SelectNodes('/status/target/entry[wc-status/@item != "unversioned"]') | Foreach-Object {$_.path};
# create a temp file of targets
$fileListPath =  [IO.Path]::GetTempFileName();
$fileList | out-file $fileListPath -Encoding ASCII
# do the commit
svn commit --targets $fileListPath -m "Publish $version" --keep-changelists 
# remove the temp file
Remove-Item $filelistPath

Update of user88044's script.更新 user88044 的脚本。

The idea is to push the files in the do-not-commit changelist and run the evil script.这个想法是推送不提交更改列表中的文件并运行邪恶的脚本。

The script extracts the do-not-commit files from the command : svn status --changelist 'do-not-commit'该脚本从命令中提取不提交文件:svn status --changelist 'do-not-commit'

#! #! /bin/bash DIR="$(pwd)" /bin/bash DIR="$(pwd)"

IGNORE_FILES="$(svn status --changelist 'do-not-commit' | tail -n +3 | grep -oE '[^ ]+$')" IGNORE_FILES="$(svn status --changelist 'do-not-commit' | tail -n +3 | grep -oE '[^ ]+$')"

for i in $IGNORE_FILES;对于 $IGNORE_FILES 中的 i; do mv $DIR/$i $DIR/"$i"_;做 mv $DIR/$i $DIR/"$i"_; done;完毕;

svn "$@"; svn "$@";

for i in $IGNORE_FILES;对于 $IGNORE_FILES 中的 i; do mv $DIR/"$i"_ $DIR/$i;做 mv $DIR/"$i"_ $DIR/$i; done;完毕;

The script is placed in /usr/bin/svnn (sudo chmod +x /usr/bin/svnn)脚本放在/usr/bin/svnn (sudo chmod +x /usr/bin/svnn)

svnn status, svnn commit, etc... svnn 状态、svnn 提交等...

You can configure the "ignore-on-commit" changelist directly with TortoiseSVN.您可以直接使用 TortoiseSVN 配置“提交时忽略”更改列表。 No need to configure any other changelist including all the others files无需配置任何其他更改列表,包括所有其他文件

1) Click "SVN Commit..." (we will not commit, just a way to find a graphical menu for the changelist) 2) On the list Right click on the file you want to exclude. 1) 单击“SVN Commit...”(我们不会提交,只是一种为更改列表找到图形菜单的方法) 2) 在列表中右键单击要排除的文件。 3) Menu: move to changelist > ignore-on-commit 3)菜单:移动到更改列表>忽略提交

The next time you do a SVN Commit... The files will appear unchecked at the end of the list, under the category ignore-on-commit.下次您执行 SVN 提交时... 文件将显示在列表末尾的忽略提交类别下未选中。

Tested with : TortoiseSVN 1.8.7, Build 25475 - 64 Bit , 2014/05/05 20:52:12, Subversion 1.8.9, -release测试: TortoiseSVN 1.8.7, Build 25475 - 64 Bit , 2014/05/05 20:52:12, Subversion 1.8.9, -release

This is late to the game, but I found the most awesome-est command line command for this problem.这已经晚了,但我找到了解决这个问题的最棒的命令行命令。 Done using bash.使用 bash 完成。 Enjoy.享受。

svn status | grep -v excluding | sed 's/^A */"/g; s/$/"/g' | tr '\n' ' ' | xargs svn commit -m "My Message"

Ok, so here's an explanation of the command.好的,这里是命令的解释。 Some things will need to be changed based on your use case.有些事情需要根据您的用例进行更改。

svn status

I get a list of all the files.我得到了所有文件的列表。 They'll all start with those status characters (?, !, A, etc).它们都以这些状态字符(?、!、A 等)开头。 Each is on its own lines每个都在自己的线上

grep -v excluding

I use grep to filter the list.我使用 grep 来过滤列表。 It can either be used normally (to include) or with the -v flag (to exclude).它可以正常使用(包括)或与 -v 标志(排除)一起使用。 In this case, it's being used to exclude, with a phrase "excluding" being what will be excluded.在这种情况下,它用于排除,短语“排除”是将被排除的内容。

sed 's/^. */"/g; s/$/"/g'

Now I remove the status character and whitespace at the beginning of each line, and then quote each line, using sed.现在我删除每行开头的状态字符和空格,然后使用 sed 引用每行。 Some of my filenames have spaces in them, hence the quoting.我的一些文件名中有空格,因此引用。

tr '\n' ' '

Using tr, I replace all newlines with spaces.使用 tr,我用空格替换所有换行符。 Now my entire list of files to commit is on one line.现在我要提交的整个文件列表都在一行上。

xargs svn commit -m "My Message"

Lastly, I use xargs to execute my commit command with the message.最后,我使用 xargs 执行带有消息的提交命令。 It does the commit, and drops my quoted file list as the last argument.它执行提交,并将我引用的文件列表作为最后一个参数删除。

The result is that everything ultimately works the way that I want it to.结果是一切最终都按照我想要的方式工作。 I still kind of hate svn for forcing me to jump through these goddamn hoops, but I can live with this.我仍然有点讨厌 svn 强迫我跳过这些该死的箍,但我可以忍受。 I guess.我猜。

I would instead write a helper bash script that runs svn commit on all the files you need to and none of the ones you don't.相反,我会编写一个帮助程序 bash 脚本,该脚本在您需要的所有文件上运行svn commit ,而没有您不需要的文件。 This way you have much more control.这样你就有更多的控制权。

For example, with one line, you can commit all files with extension .h and .cpp to which you made changes (and which wouldn't cause a conflict):例如,在一行中,您可以提交所有扩展名为.h.cpp文件,您对其进行了更改(并且不会导致冲突):

svn commit -m "" `svn status | grep "^M.*[h|cpp]$" | awk '{print $2}' | tr "\\n" " "`

Change / add extensions to the [h|cpp] part.更改/添加扩展到[h|cpp]部分。 Add a log message in between the quotes of -m "" if needed.如果需要,在-m ""的引号之间添加一条日志消息。

As I was facing the exact same issue, and my googling kept giving me nothing, I think I found a workaround.当我面临完全相同的问题时,我的谷歌搜索一直没有给我任何信息,我想我找到了一个解决方法。 Here's what I did, it seems to work for me, but as I'm stuck with an old version of SVN (< 1.5, as it doesn't have the --keep-local option) and I'm no expert of it, I can't be sure it's an universal solution.这就是我所做的,它似乎对我有用,但是因为我坚持使用旧版本的 SVN(< 1.5,因为它没有 --keep-local 选项)而且我不是专家,我不能确定这是一个通用的解决方案。 If it works for you too, please let me know !如果它也适用于您,请告诉我!

I was dealing with a Prestashop install I got from SVN, since other people had already started working on it.我正在处理我从 SVN 获得的 Prestashop 安装,因为其他人已经开始使用它。 Since the DB settings were done for another server, I changed them in some file in the /config folder.由于数据库设置是为另一台服务器完成的,我在 /config 文件夹中的某个文件中更改了它们。 As this folder was already versioned, setting it in svn:ignore would not prevent my local modifications on it from being committed.由于这个文件夹已经版本化,在 svn:ignore 中设置它不会阻止我对它的本地修改被提交。 Here's what I did :这是我所做的:

cp config ../cfg_bkp              # copy the files out of the repo
svn rm config                     # delete files both from svn and "physically"
svn propset svn:ignore "config" . # as the files no longer exists, I can add my ignore rule and then...
mv ../cfg_bkp config              # ...bring'em back
svn revert --recursive config     # make svn forget any existing status for the files (they won't be up for deletion anymore)

Now I can run svn add --force .现在我可以运行 svn add --force 。 at the repo root without adding my config, even if it's not matching the repo's version (I guess I would have to go through all this again if I modified it one more time, did not test).在不添加我的配置的 repo root 中,即使它与 repo 的版本不匹配(我想如果我再修改一次,我将不得不再次经历所有这些,没有测试)。 I can svn update as well without having my files being overwritten or getting any error.我也可以 svn update ,而不会覆盖我的文件或出现任何错误。

A solution that does not ignore changes in directory properties不忽略目录属性更改的解决方案

I tried to use the solution based on changelist , but I have a couple of issues with it.我尝试使用基于changelist的解决方案,但我有几个问题。 First my repository has thousand of files, so the changelist to be committed is huge, and my svn status output became way too long and needed to be parsed to be useful.首先,我的存储库有数千个文件,因此要提交的更改列表很大,而且我的svn status输出变得太长,需要进行解析才能有用。 Most important is that I wanted to commit changes that came from a merge, which means they include property changes.最重要的是,我想提交来自合并的更改,这意味着它们包括属性更改。 When committing a changelist, the svn properties attached to the directory are not committed, so I had to do an extra commit:提交更改列表时,未提交附加到目录的 svn 属性,因此我必须进行额外的提交:

svn ci --cl work -m "this commits files from the work changelist only"
svn up
svn ci --depth empty DIR . -m "record merge properties"

You may have to do that for several directories (here I record the properties of DIR and of the current dir . ), basically those with a M in the second column when issuing the svn status command.您可能必须对多个目录执行此操作(这里我记录了DIR和当前 dir 的属性. ),基本上是在发出svn status命令时第二列中带有M那些。

Solution解决方案

I used patches and svn patch .我使用了补丁和svn patch In pseudo-code:在伪代码中:

svn diff $IGNORE_FILES > MYPATCH   # get the mods to ignore
svn patch --reverse-diff MYPATCH   # remove the mods
svn ci -m "message"                # check-in files and directory properties
svn patch MYPATCH                  # re-apply the mods

Like other posters, I end up using a script to maintain the list of files to ignore:像其他海报一样,我最终使用脚本来维护要忽略的文件列表:

#! /usr/bin/env bash

finish() {
    svn patch MYPATCH               # re-apply the mods
}
trap finish EXIT

IGNORE_FILES="\
sources/platform/ecmwf-cca-intel-mpi.xml \
runtime/classic/platform/ecmwf-cca.job.tmpl \
runtime/classic/platform/ecmwf-cca-intel.xml"

svn diff $IGNORE_FILES > MYPATCH # get the mods to ignore
svn patch --reverse-diff MYPATCH # remove the mods

svn "$@"

I typically used it with ci and revert -R .我通常将它与cirevert -R . . .

If you are on linux, below answer will be useful如果您使用的是 linux,以下答案将很有用

Step 1 Create .svnignore file in root level of your working copy, and add folders/files in each new line(eg, below)步骤 1在工作副本的根级别创建.svnignore文件,并在每个新行中添加文件夹/文件(例如,下面)

\.
folder1
folder2
folder3/file2.html
folder4/file1.js

Note: You also need to add \\.注意:您还需要添加\\. as that points to root directory因为它指向根目录

Tip: To get exact folder/file path, run svn st -u then copy and paste same path in .svnignore file提示:要获得确切的文件夹/文件路径,请运行svn st -u然后将相同的路径复制并粘贴到.svnignore文件中

Step 2 Run below command to commit everything except folder/files from .svnignore file步骤 2运行以下命令以提交除.svnignore文件中的文件夹/文件之外的所有内容

svn ci -m "YOUR-COMMENT-HERE" $(svn st | grep -v -w -f .svnignore | awk '{print $NF}')

Command Explanation命令说明

╔════════════════════╦════════════════════════════════════════════════════════════════════════════════════════════════════════╗
║ svn ci             ║ Shorthand for svn commit                                                                               ║
╠════════════════════╬════════════════════════════════════════════════════════════════════════════════════════════════════════╣
║ svn st             ║ Shorthand for svn status                                                                               ║
╠════════════════════╬════════════════════════════════════════════════════════════════════════════════════════════════════════╣
║ |                  ║ Pipe(|) is used to pass output of previous command to next command's input                             ║
╠════════════════════╬════════════════════════════════════════════════════════════════════════════════════════════════════════╣
║ grep               ║ grep is a linux command to filter                                                                      ║
╠════════════════════╬════════════════════════════════════════════════════════════════════════════════════════════════════════╣
║ grep -v            ║ Give result other than matched (Inverse)                                                               ║
╠════════════════════╬════════════════════════════════════════════════════════════════════════════════════════════════════════╣
║ grep -w            ║ Exact match(used to match literal Dot(.))                                                              ║
╠════════════════════╬════════════════════════════════════════════════════════════════════════════════════════════════════════╣
║ grep -f filename   ║ Read pattern from file                                                                                 ║
╠════════════════════╬════════════════════════════════════════════════════════════════════════════════════════════════════════╣
║ awk '{print $NF}') ║ print last column data (columns are divided with space delimiter), used to get exact folder/file names ║
╚════════════════════╩════════════════════════════════════════════════════════════════════════════════════════════════════════╝

svn:ignore is your answer. svn:ignore是你的答案。

Example:例子:

$ svn propset svn:ignore -F .cvsignore .
property 'svn:ignore' set on '.'
svn propset "svn:ignore" "*.xml" .

the *.xml is the pattern of files to ignore; *.xml是要忽略的文件模式; you can use directory names here as well.您也可以在此处使用目录名称。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM