我正在和很多人一起开发。
我签出远程存储库,获取 3 个文件。编辑后运行:
svn status
表明:
M file_1
M file_2
M file_3
现在,我只想提交两个文件:file_1、file_2,而不是 file_3。
怎么做?
我不想用
svn revert file_3
在提交之前。
说明:我编辑 file_1,file_2 用于共享项目,file_3 仅在我的本地计算机上运行。
扩展zoul的答案..来开发您的文件列表,请使用:
svn stat | grep -v ignore.file | perl -ne 'chop; s/^.\s+//; print "$_ "'
或者,如果您有带空格的文件名,请使用:
svn stat | grep -v ignore.file | perl -ne 'chop; s/^.\s+//; print "\"$_\" "'
怎么样:
$ svn commit file_1 file_2
bash 一行:
svn ci $(svn stat | grep -v exclude.file)
只需将要提交的文件的路径附加到 svn commit 命令:
svn commit file_1 file_2
见http://svnbook.red-bean.com/en/1.7/svn.ref.svn.c.commit.html
我最终制作了一个包含以下内容的脚本:
svn ci $(svn diff --summarize | \
grep -v exclude.file1 | \
grep -v exclude.file2 | \
...
grep -v exclude.fileN \
)
我相信有人可以通过让这个脚本读取一个包含要从提交中排除的文件列表的文件来使其更加灵活。
这是一个 windows powershell 版本,它只提交不在更改列表中的文件。创建一个名为 ignore-on-commit 的更改列表(Tortoise SVN 无论如何都会理解)并将您不想提交的文件放入其中。
# 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
也许你可以使用这个命令。
svn ci `svn st | grep -e "^[A|M]" | grep -v "test.js" | grep -ve "conf\.js$" | awk '{print $2}' | tr "\\n" " "`