1. how to display differences between two different revisions of a file in SVN
  2. The main idea is the following command:
    svn diff --diff-cmd diff -x -uw -r 4050:4054 database/vo-common-dml.sql
    The results can be visually improved by two ways:
  3. SVN undo delete before commit
  4. before commit:
    svn revert deletedDirectory-or-file
  5. how to bring back from the dead an entire directory that has been svn rmed and svn commited
  6. I accidentaly svn rmed two directories. I.e. instead of doing the following:
    svn mv dir-a dir-b && svn commit -m "foo"
    … which was my intention, I mistyped and executed the dreaded:
    svn rm dir-a dir-b && svn commit -m "foo"
    The following command (executed at the root of my entire repository) save the day:
    svn merge -r COMMITTED:PREV .
    (followed by a svn commit).
  7. get a previous version of a file
  8. svn update -r 666 file

    … or to just view it without changing the working copy:
    svn cat -r 666 file | less
  9. do a visual diff between a file and a revision of it
  10. svn diff -r 2250 [filename] --diff-cmd meld
  11. show which commits changed a specific file
  12. svn blame [filename]
  13. message "obstructing working copy was found"
  14. I've encountered the following message upon svn update:
    $ svn update
    Updating '.':
    Skipped 'ivoa-console-utils/sval' -- An obstructing working copy was found
    At revision 3257.
    Summary of conflicts:
      Skipped paths: 1
    Sometimes just doing an svn cleanup seems to work.

    Otherwise try the following (in conjunction with a cleanup):
    1. mv the .svn directory out of the way to some other location in the filesystem (outside of the SVN tree)
    2. do an svn update and svn status (you should see a bunch of files marked with `D`)
    3. mv the .svn directory back in place
    4. svn update is now (mysteriously) clean.

    Or also try instead of the above silly moving around of directories to svn co the problematic directory somewhere outside the SVN tree and then move it in place (after rm-ing the previous directory that existed in its place), again in conjunction with svn cleanup.

    Sprinkle the above instructions liberally with a few svn revert too. Yeah, it's a bit ugly and non-deterministic I am afraid.
  15. dreaded tree conflicts
  16. A response like the following upon svn status (following a svn update):
    $ svn status
    D     C sval
          >   local unversioned, incoming add upon update
    ... probably indicates a tree conflict. What has worked for me (assuming the above directory name) is:
    $ svn resolve --accept working sval
    Resolved conflicted state of 'sval
    $ svn revert sval
    Reverted 'sval'
    $ svn status
    (following the advices found here and here).

    However oftentimes even the above doesn't work and then (after following the above steps) I resorted to executing the following sequence of actions:
    1. deleting the directory locally
    2. doing a svn co of the problematic directory in some other location
    3. mv-ing the just checked-out directory to where it is supposed to be

    Of course this wipes any untracked files so better than deleting the directory in step #1 above is to just move it out of the way so you can copy back any untracked files after step #3.
  17. recover deleted files from an SVN repository
  18. Find the revision on which the file was present with svn log --verbose.
    Then, (assuming the revision was 'r144' and the file 'foo') do a:
    svn up -r 144 foo
    It seems to correctly restore directories too (all files in said directory are restored to the state they had as of that revision).
  19. to add all local files (but not the ignored ones)
  20. source
    On the Commandline you can't use
    svn add *
    This will also add the ignored files, because the command line expands * and therefore svn add believes that you want all files to be added. Therefore use this instead:
    svn add --force .
  21. un-add files in SVN
  22. svn revert --recursive folder_name
    svn rm --keep-local folder_name
  23. recursively add new ignored patterns in SVN
  24. See my svn-rec-add-ignore.sh script (in ~/tools).
  25. recursively set ignored pattern in SVN
  26. svn propset --recursive svn:ignore --file /path/to/a/file/with/svn-ignore-rules .
  27. show ignored files in a directory
  28. svn pg svn:ignore .
    or (but that shows all properties, not just svn:ignore):
    svn proplist -v .
  29. remove directory from SVN version control (but not local contents)
  30. svn rm --keep-local dirname
    (why one would want to do that is unclear)
  31. add all unversioned files to SVN
  32. svn add --force * --auto-props --parents --depth infinity -q
    - so, NB: doesn't seem to add dot files, subsumed in my svn-add-all.sh script (in ~/tools)
  33. edit svn:ignore at current dir (to ignore or unignore files)
  34. svn propedit svn:ignore .
  35. delete all unversioned / ignored files in working copy
  36. svn status | grep '^?' | awk '{print $2}' | xargs rm -rf
  37. see which commits modified which lines of a file
  38. svn blame ./path/to/file.java | sort -n
  39. procedure to revert to an older revision and then back again
    1. [to revert:] svn update -r 4303
    2. [to return:] svn revert -R .
  40. procedure to merge a branch' directory onto the trunk's respective directory
    1. verify that both the trunk and the branch are clean with respect to svn update and svn status
    2. [in trunk:] svn info | grep ^URL
    3. [in trunk:] svn merge
  41. throw away all uncommited changes in working copy:
  42. svn revert -R .
  43. show differences between a revision (left) and the working copy of a file (right):
  44. svn diff -r 4703 ./relative/path/to/filename.cpp
  45. helpful SVN log that shows the paths modified in a commit
  46. svn log -v | head -30
  47. how to merge a specific revision of a file in SVN
  48. svn merge -c1501 filename
    Note that the semantics of the above command are: 'merge the changes found in the specific revision of the file relative to the immediately previous revision (in this case, 1500).

    To merge a whole contiguous range of revisions you do a:

    svn merge -c1000:1501 filename
  49. the dreaded '<some-dir>/.svn containing working copy admin are is missing' problem in SVN
  50. What has worked for me is the following sequence:
    1. svn co in some other location
    2. cp -pr .svn to where it's supposed to go
    3. (not always - depending on the circumstances)
    4. doing a svn rm --force <some-dir>
    The second step gets dir of the '~' SVN status symbol and I can then proceed to either remove the offending folder (if that was the intention) or what have you. See also this SO article
  51. add a directory foodir to SVN but not its contents:
  52. svn add --depth=empty foodir
    - or -
    svn add -N [directory]
  53. add a number of files in the svn:ignore property
  54. svn propedit svn:ignore .
  55. add a directory in SVN without recursing
  56. svn add --depth=empty <directory>
  57. reverting an 'svn add <directory>'
  58. svn revert <directory>
    and sometimes the following is required:
    svn revert <directory> --depth infinity
  59. checking out a particular working directory inside the repo
  60. svn co
  61. checking that status of a file (e.g. foo.sh) in SVN
  62. svn ls foo.sh
  63. getting the .svnignore settings for the current folder
  64. svn propget svn:ignore .
  65. renaming, moving files / directories and creating directories
  66. Such operations cannot be done from the shell alone. You'll have to use:
    svn mv
    svn mkdir
  67. how to add ignore files in SVN
  68. use the setUnversionedToSVNignore.sh script once you're satisfied that all the files reported with '?' in the svn status are files you want to add to svn:ignore. Then, to commit the svn:ignore properties of the folders thusly changed its enough to commit the roo folder, or each one of them individually.
  69. how to undo SVN commits
  70. Say you wish to go back from commit 75 to commit 68. There are two ways:

    1. use svn merge
    2. do it manually
    With the svn merge route you do a:
    svn merge -r 75:68
    followed by a new SVN commit to push the reverted r68 to the tip.

    With the manual way, you create a new folder just to checkout the previous version you wish to revert to (say r68) and do some file-hacking there. Let's call that folder "r68checkoutFolder". This is the source folder for most of the below operations. The target folder is the "checkout75" (latest commit SVN tip) folder. So, in the r68checkoutFolder you do a:

    svn checkout -r 68
    Then you remove all metadata svn files using:
    find . -iname .svn | xargs rm -rf
    Now you want to remove from the target (latest release folder) all files that were added since r68. So you do a:
    cd /path/to/checkout68 ; find . -type f -exec rm /path/to/checkout75/'{}' \;
    Then you remove all files in r68 that are identical in r75. To do that we use the ttsiodras utility cmpDir1andDir2andRemoveSamesFromDir1:
    cmpDir1andDir2andRemoveSamesFromDir1 r68checkoutFolder /path/to/checkout75
    And then remove all empty folders using:
    find . -type d -depth | xargs rmdir
    At this point, what's left in the r68checkoutFolder is the files that were modified between revisions 68 and 75. And we are also guaranteed that any new files in r75 have been deleted. So all that's left is move the remaining files over to r75:
    find . -type f -exec mv '{}' /path/to/checkout75/'{}' ';'
    At the end of the move it should be the case that the source folder is empty. If this is so, we can then follow and close the manual process with a commit at the target folder:
    svn commit -m "manually reverted back to r68"
  71. basic SVN vocabulary
  72. checkout, update, status, info, log, commit, add, rm

    svn revert 'filename' '.' 'foldername'

    svn commit -m "message" 'filename' (or no 'filename' for all modified files

  73. SVN status symbols
  74. svn / git correspondances