简体   繁体   English

SVN提交特定文件

[英]SVN Commit specific files

Is there any way to commit only a list of specific files (eq just one of the list of files that SVN wants to commit). 有没有办法只提交特定文件列表(eq只是SVN想要提交的文件列表之一)。

I'm working on MAC OS X under Terminal, without any UI. 我正在终端下的MAC OS X上工作,没有任何UI。

Sure. 当然。 Just list the files: 只需列出文件:

$ svn ci -m "Fixed all those horrible crashes" foo bar baz graphics/logo.png

I'm not aware of a way to tell it to ignore a certain set of files. 我不知道告诉它忽略某组文件的方法。 Of course, if the files you do want to commit are easily listed by the shell, you can use that: 当然,如果你想要提交的文件很容易被shell列出,你可以使用:

$ svn ci -m "No longer sets printer on fire" printer-driver/*.c

You can also have the svn command read the list of files to commit from a file: 您还可以让svn命令读取要从文件提交的文件列表:

$ svn ci -m "Now works" --targets fix4711.txt

Use changelists. 使用更改列表。 The advantage over specifying files is that you can visualize and confirm everything you wanted is actually included before you commit. 指定文件的优点是,您可以在提交之前可视化并确认您想要的所有内容。

$ svn changelist fix-issue-237 foo.c 
Path 'foo.c' is now a member of changelist 'fix-issue-237'.

That done, svn now keeps things separate for you. 完成后,svn现在为你保持独立。 This helps when you're juggling multiple changes 当您处理多项更改时,这会有所帮助

$ svn status
A       bar.c
A       baz.c

--- Changelist 'fix-issue-237':
A       foo.c

Finally, tell it to commit what you wanted changed. 最后,告诉它提交你想要改变的内容。

$ svn commit --changelist fix-issue-237 -m "Issue 237"

您基本上将要提交的文件放在命令行上

svn ci file1 file2 dir1/file3

Due to my subversion state, I had to get creative. 由于我的颠覆状态,我不得不发挥创造力。 svn st showed M , A and ~ statuses. svn st显示MA~状态。 I only wanted M and A so... 我只想要MA ......

svn st | grep ^[A\|M] | cut -d' ' -f8- > targets.txt

This command says find all the lines output by svn st that start with M or A , cut using space delimiter, then get colums 8 to the end. 此命令说找到svn st输出的所有行,以MA开头,使用空格分隔符剪切,然后将colums 8添加到结尾。 Dump that into targets.txt and overwrite. 将其转储到targets.txt并覆盖。

Then modify targets.txt to prune the file list further. 然后修改targets.txt以进一步修剪文件列表。 Then run below to commit: 然后运行以下提交:

svn ci -m "My commit message" --targets targets.txt

Probably not the most common use case, but hopefully it helps someone. 可能不是最常见的用例,但希望它可以帮助某人。

Besides listing the files explicitly as shown by unwind and Wienczny , you can setup change lists and checkin these. 除了显示unwindWienczny所显示的文件 ,您还可以设置更改列表并签入这些文件。 These allow you to manage disjunct sets of changes to the same working copy. 这些允许您管理对同一工作副本的分离更改集。

You can read about them in the online version of the excellent SVN book . 您可以在优秀的SVN书在线版中阅读它们。

try this script.. 试试这个脚本..

#!/bin/bash
NULL="_"
for f in `svn st|grep -v ^\?|sed s/.\ *//`; 
     do LIST="${LIST} $f $NULL on"; 
done
dialog --checklist "Select files to commit" 30 60 30 $LIST 2>/tmp/svnlist.txt
svn ci `cat /tmp/svnlist.txt|sed 's/"//g'`

I make a (sub)folder named "hide", move the file I don't want committed to there. 我做一个名为“隐藏”(子)文件夹,将我不想承诺存在的文件。 Then do my commit, ignoring complaint about the missing file. 然后做我的提交,忽略对丢失文件的投诉。 Then move the hidden file from hide back to ./ 然后将隐藏文件从隐藏文件移回./

I know of no downside to this tactic. 我知道这种策略没有任何缺点。

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

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