Exclude some files on svn command line commit (not svn:ignore)

拈花ヽ惹草 提交于 2020-01-21 10:45:10

问题


I'm developing with many people.

I check out remote repository, get 3 file. After edit, run:

svn status

It shows:

M file_1
M file_2
M file_3

Now, I want to commit only two file: file_1, file_2, but not file_3.

How to do it?

I dont' want to use

svn revert file_3

before commit.

Explain: I edit file_1, file_2 for shared project, file_3 for running on only my local machine.


回答1:


How about:

$ svn commit file_1 file_2



回答2:


Expanding upon zoul's answer.. to develop your list of files use:

svn stat |  grep -v ignore.file | perl -ne 'chop; s/^.\s+//; print "$_ "'

Or if you have file names with spaces use:

svn stat |  grep -v ignore.file | perl -ne 'chop; s/^.\s+//; print "\"$_\" "'



回答3:


one line for bash:

svn ci $(svn stat | grep -v exclude.file)



回答4:


Just append the paths of the files to commit to the svn commit command:

svn commit file_1 file_2

See http://svnbook.red-bean.com/en/1.7/svn.ref.svn.c.commit.html




回答5:


Here's a windows powershell version that commits only files that aren't in a changelist. Create a changelist called ignore-on-commit (which Tortoise SVN will understand anyway) and put the files you don't want to commit into it.

# 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



回答6:


I wound up making a script containing the following:

svn ci $(svn diff --summarize | \
    grep -v exclude.file1 | \
    grep -v exclude.file2 | \
    ...
    grep -v exclude.fileN \
)

I'm sure someone can make it even more flexible by making this script read a file which would contain a list of files to be excluded from the commit.




回答7:


maybe you can use this command.

svn ci `svn st | grep -e "^[A|M]" | grep -v "test.js" | grep -ve "conf\.js$" | awk '{print $2}' | tr "\\n" " "`


来源:https://stackoverflow.com/questions/8517064/exclude-some-files-on-svn-command-line-commit-not-svnignore

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!