3

I have a long list of *.aspx and *.aspx.cs files that I want to commit at once, without committing other files with other file extensions. What I am currently doing is this:

svn commit path\to\one.aspx, path\to\two.aspx, path\to\N.aspx.cs -m "Message"

What I would like to do instead is something like this:

svn commit *.aspx, *.aspx.cs -m "Message"

I'm afraid the above does not work. What would?

Edit: Clarify that the files exist in sub-directories.

I have looked at Can you specify filenames using wildcards or regexes in the subversion mv command? It is about moving a file not committing it.

5
  • possible duplicate of Can you specify filenames using wildcards or regexes in the subversion mv command? Commented Apr 20, 2015 at 20:06
  • 1
    This question is about svn commit. The "possible duplicate" listed is for svn mv. I don't think that's a duplicate. Commented Apr 20, 2015 at 21:47
  • 1
    I THINK from comments on answers, that the further clarifications apply to this question: the files are actually in subdirectories (so the example "what I am currently doing" command won't actually work), and the files already exist in SVN (so no need to svn add them first). Commented Apr 22, 2015 at 14:35
  • @Ben That sounds good. Based on the further clarifications, would you be will to offer an answer? Commented Apr 22, 2015 at 15:51
  • Done, in a second answer. Please accept if it works for you. Commented Apr 22, 2015 at 16:47

3 Answers 3

3

From the comments on my other answer, your problem is that you are expecting SVN to recursively search every subdirectory for files matching a wildcard pattern. SVN does not do this. SVN relies on your shell to expand wildcards.

The solution depends on your situation.

If all files you want to commit are in the same common directory, simply cd path/to/common/dir and commit as you are doing (but leave out the comma). You can commit from anywhere within your working copy, but when you do, only the files in that directory tree will be committed.

If you have multiple directories to commit it gets more complicated, depending on what OS you are running on.

Unix-like systems have a ** wildcard meaning "0 or more directory paths", so this should work on Linux or Unix:

svn commit **/*.aspx **/*.aspx.cs -m "message"

Windows doesn't understand the ** wildcard, so you need to specify each on the command line. For example (backslashes for path separators, since I'm assuming Windows here):

svn commit subdir1\*.aspx subdir1\*.aspx.cs subdir2\*.aspx subdir2\*.aspx.cs -m "message"

If you have too many subdirectories for this, simply create a file listing all the files you want to commit, and use that for your file list:

dir /B /S *.aspx *.aspx.cs > file_list.txt
svn commit --targets file_list.txt -m "message"

This last example should also work on Unix-like systems, if you don't like using the ** wildcard (using ls or find with appropriate options instead of dir). It will also let you edit the commit list if you like, before committing, by modifying file_list.txt before you commit.


Edit: Rather than a file, you could make use of a "changelist" to store file names to commit. See the other answers for how to build a changelist.

Sign up to request clarification or add additional context in comments.

Comments

3

From only the details given in the question, one would expect it to work with "*" wildcard as follows, unless there is something else:-

/myrepo/trunk/test>svn commit *.txt *.java -m "Minor modifications"
Sending        New.java
Sending        Readme.txt
Sending        myfile.txt
Transmitting file data ...
Committed revision 15.

You can also use svn changelist for easy identification:-

/myrepo/trunk/test>svn changelist "Text files" *.txt
Path 'myfile.txt' is now a member of changelist 'Text files'.
Path 'Readme.txt' is now a member of changelist 'Text files'.
/myrepo/trunk/test>svn changelist "Text files" *.java
Path 'New.java' is now a member of changelist 'Text files'.
/myrepo/trunk/test>svn status
--- Changelist 'Text files':
M       myfile.txt
        New.java
M       Readme.txt
/myrepo/trunk/test>svn commit --changelist "Text files" -m "Minor modifications"
Sending        test/Readme.txt
Sending        test/myfile.txt
Transmitting file data
.. Committed revision 16.

Note: It would be helpful, if you could share some more details like error message.

2 Comments

And what does "svn status" show? Does it show these files as versioned and modified?
I like this answer because of the recommendation of change lists, which you could build up from several subdirectories and avoid the use of a throwaway file as in my answer.
-1

Leave out the comma; it is unnecessary and your shell is just treating it as part of the file name. I.e. your command should be simply:

svn commit *.aspx *.aspx.cs -m "message"

5 Comments

I just tried the following and it didn't work for adding a .ascx file. svn commit *.ascx -m "Update comments."
Oh, so you DO want to add new files. You need the svn add command from the other answer then, but without the commas. "Commit" is for committing changes to files already in version control, or making an add permanent. But to get them in version control in the first place you need to tell svn to add them.
I want to commit them not add them. My mistake in the comment.
Are these ascx files in the same directory as you are running the command in?
No, they are not in the same directory.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.