SVN Commit specific files

SvnTerminal

Svn Problem Overview


Is there any way to commit only a list of specific files (e.q. just one of the list of files that SVN wants to commit).

I'm working on MAC OS X under Terminal, without any UI.

Svn Solutions


Solution 1 - Svn

Sure. Just list the files:

$ svn ci -m "Fixed all those horrible crashes" foo bar baz graphics/logo.png

I'm not aware of a way to tell it to ignore a certain set of files. Of course, if the files you do want to commit are easily listed by the shell, you can use that:

$ svn ci -m "No longer sets printer on fire" printer-driver/*.c

You can also have the svn command read the list of files to commit from a file:

$ svn ci -m "Now works" --targets fix4711.txt

Solution 2 - Svn

Use changelists. The advantage over specifying files is that you can visualize and confirm everything you wanted is actually included before you commit.

$ svn changelist fix-issue-237 foo.c 
Path 'foo.c' is now a member of changelist 'fix-issue-237'.

That done, svn now keeps things separate for you. This helps when you're juggling multiple changes

$ svn status
A       bar.c
A       baz.c

--- Changelist 'fix-issue-237':
A       foo.c

Finally, tell it to commit what you wanted changed.

$ svn commit --changelist fix-issue-237 -m "Issue 237"

Solution 3 - Svn

You basically put the files you want to commit on the command line

svn ci file1 file2 dir1/file3

Solution 4 - Svn

Due to my subversion state, I had to get creative. svn st showed M,A and ~ statuses. I only wanted M and A so...

svn st | grep ^[A\|M] | cut -d' ' -f8- > targets.txt

This command says find all the lines output by svn st that start with M or A, cut using space delimiter, then get colums 8 to the end. Dump that into targets.txt and overwrite.

Then modify targets.txt to prune the file list further. Then run below to commit:

svn ci -m "My commit message" --targets targets.txt

Probably not the most common use case, but hopefully it helps someone.

Solution 5 - Svn

Besides listing the files explicitly as shown by unwind and Wienczny, you can setup change lists and checkin these. These allow you to manage disjunct sets of changes to the same working copy.

You can read about them in the online version of the excellent SVN book.

Solution 6 - Svn

try this script..

#!/bin/bash
NULL="_"
for f in `svn st|grep -v ^\?|sed s/.\ *//`; 
     do LIST="${LIST} $f $NULL on"; 
done
dialog --checklist "Select files to commit" 30 60 30 $LIST 2>/tmp/svnlist.txt
svn ci `cat /tmp/svnlist.txt|sed 's/"//g'`

Solution 7 - Svn

I make a (sub)folder named "hide", move the file I don't want committed to there. Then do my commit, ignoring complaint about the missing file. Then move the hidden file from hide back to ./

I know of no downside to this tactic.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Question0100110010101View Question on Stackoverflow
Solution 1 - SvnunwindView Answer on Stackoverflow
Solution 2 - SvnjcwengerView Answer on Stackoverflow
Solution 3 - SvnWiencznyView Answer on Stackoverflow
Solution 4 - SvnEricView Answer on Stackoverflow
Solution 5 - SvnsbiView Answer on Stackoverflow
Solution 6 - SvnAbhijit DhariyaView Answer on Stackoverflow
Solution 7 - SvnGeorge WycheView Answer on Stackoverflow