简体   繁体   中英

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

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.

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 "\"$_\" "'

怎么样:

$ svn commit file_1 file_2

bash一行:

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

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

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

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.

也许你可以使用这个命令。

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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