webster
webster

Reputation: 4032

Is it possible to skip certain files from being commited in SVN?

I am using SVN in my Ruby on Rails project. I have changed a number of files.

I usually commit my changes using:

svn commit -m "test_commit"

Its possible to commit individual files using:

svn ci -m "test_commit" file1 file2 dir/file3

But in this case I have almost 40 files to be commited. So adding all the file locations is a tedious task.

So I want to skip a couple of files and then commit it. Is it possible in SVN?

Upvotes: 0

Views: 49

Answers (2)

David W.
David W.

Reputation: 107090

You can create a change list in Subversion. Change lists are a way of grouping files for a common action. Commands such as svn commit, svn revert, svn status, and the various properties commands can all operate on a change list.

To create a changelist, use the svn changelist or svn cl command:

$ svn changelist <change_List_Name> <file> [<file2....>]

If there are too many files, you can use the --targets parameter to specify a file that contains the list of files you want to put in a change list:

$ svn changelist --targets <file_name>

For example, you could create your changelist file with `

file.txtthen edit thatfile.txt` to contain only the files you want to commit.

Then, use:

$ svn commit --changelist <change_list_name>

to commit just the files you want. Or,

$ svn commit --cl --keep-changelists

To keep that changelist of files in case you do more work on them.

Of course, you could forget changelists and just try the --targets parameter of the svn commit command. This is suppose to allow you to list files you want to commit in another file (much like how the --targets parameter works with svn changelist). I haven't tried that particular one, so I can't say how that works.


Addendum

Could you please explain 'svn changelist --targets ' with another example?

Imagine I have a working copy, and I've run svn st on it:

$ svn st
? foo.txt
M bar/bar.txt
D foofoo/foo.out
A barfu/barbar.sh

I am fixing Bug #103. This includes the changes to foofoo/foo.out and bar/bar.txt, but not to barfu/barbar.sh which was another bug I was working on.

If I run the the following:

$ svn status | awk '/^[MDA]/ {print $2}'
bar/bar.txt
foofoo/foo.out
barfu/barbar.sh

Notice that it gives me the files that were modified, deleted, and added, in my working copy, but not files in the working directory that aren't in the repo or files in the repo, but not in the working copy. This also doesn't give me a status of the files -- just the file names. I want to create a changelist for Bug #103, so I'll create a file called bug103.txt, and then edit it to remove the files that shouldn't be there:

$ svn status | awk '/^[MDA]/ {print $2}' > bug103.txt

Using my favorite text editor, I removed all the files that don't belong to Bug #103 from my `bug103.txt:

$ cat bug103.txt
bar/bar.txt
foofoo/foo.out

Now I have all of the files that deal with Bug #103 in my changelist in a file called bug103.txt, I'll create the change list for Bug #103:

$ svn cl --targets bug103.txt BUG103

Now, I can use the changelist to manipulate the status of my files. Let's check in this changelist:

$ svn --cl BUG103 -m"Fixed BUG #103"

This checked in the two files involved in Bug #103, but not barfu/barbar.sh.

Upvotes: 1

guy
guy

Reputation: 352

If the files you don't want to update are under the same directory, you can enter the first directory that doesn't contains them, and push the svn from there:

svn commit -m "comment"

try svn status before so you will be sure what you are pushing.

Upvotes: 0

Related Questions