vietstone
vietstone

Reputation: 9092

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.

Upvotes: 13

Views: 19593

Answers (7)

Poised_flw
Poised_flw

Reputation: 31

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" " "`

Upvotes: 0

Johnas Cukier
Johnas Cukier

Reputation: 690

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.

Upvotes: 1

user1699917
user1699917

Reputation: 1630

one line for bash:

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

Upvotes: 3

Ben Curthoys
Ben Curthoys

Reputation: 859

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

Upvotes: 0

Charlie Dalsass
Charlie Dalsass

Reputation: 2014

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

Upvotes: 12

JB Nizet
JB Nizet

Reputation: 691625

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

Upvotes: 1

zoul
zoul

Reputation: 104065

How about:

$ svn commit file_1 file_2

Upvotes: 9

Related Questions