Skip to content

Instantly share code, notes, and snippets.

@vpiotr
Created August 14, 2019 10:48
Show Gist options
  • Save vpiotr/3363e53702e78c062e5cdf77387a882d to your computer and use it in GitHub Desktop.
Save vpiotr/3363e53702e78c062e5cdf77387a882d to your computer and use it in GitHub Desktop.
SVN Command Quickref

Basic commands

Add

  • add files

    svn add myscript.sh
    
  • add all which are not in SVN

    svn status | grep '?' | sed 's/^.* /svn add /' | bash
    

Workdir status

  • show current revision & last change date

    svn info
    

List changes

  • list changes ignoring unknown new files

    svn status|grep -v "?   "
    
  • list pending deletes

    svn status|grep  "D  "
    
  • List changes in repo

    svn log
    
  • List changes in revision

    svn log -v -r 88853
    

Stash

  • create stash for all local changes

    svn diff > '/home/user/shared/work2016/20161201_msgs/patch/res.patch'
    svn revert --depth=infinity .
    
  • apply stash (from patch file)

    svn patch '/home/user/shared/work2016/20161201_msgs/patch/res.patch'
    
  • Create patch for diff between revisions

    svn diff -r123:124 path/to/my_project > ~/my_project_changes_123_124.patch
    

Merging

Merging - basic commands

  • merge change from a given revision and branch to current working directory.

    svn merge -c 892 http://192.168.101.1/Repository/branch/user/KSS/BUILD/PROV_ONLY/
    

Conflicts

  • resolve theirs

    svn resolve --accept=theirs-full file/path
    
  • Conflict - "local dir unversioned, incoming dir add upon update"

    $ svn resolve --accept working logs
    Resolved conflicted state of 'logs'
    $ svn revert logs
    Reverted 'logs'
    $ svn status
    
  • Resolve as working copy

    svn resolve --accept=working file/path
    

Merging - see also

Commit corrections

  • Revert selected commit - remove commit from chain of changes

    svn merge -c -13455 .
    
  • Revert all local changes

    svn revert --depth=infinity .
    
  • Revert add

    svn revert --recursive example_folder
    

Changelist

  • add files to changelist

    svn changelist 'MYCHANGE01' file1
    svn changelist 'MYCHANGE01' path/to/file/file02.txt
    
  • commit changelist

    svn commit --changelist 'MYCHANGE01' -m "deleted files"
    

Clean

  • in SVN:
    • clean status info:
      • svn cleanup
    • plus optional local revert:
      • svn revert --depth=infinity .
  • in Eclipse: Update to HEAD

Statistics

  • Commits per user

    svn log -v --xml | grep '<author.*/author>' | sort $* | uniq -c | sort -rn
    
  • Lines per user

    svn ls -R | egrep -v -e "\/$" | xargs svn blame | awk '{print $2}' | sort | uniq -c | sort -r
    

Ignores

  • List ignores - with subdirectories

    svn pg -R svn:ignore .
    
  • list ignores - only current directory

    svn pg svn:ignore .
    

Externals

  • List externals:

    svn propget -R svn:externals .
    
  • Update externals from a file:

    echo "url1:link LONG\ -\ FILE\ Path.xlsx" >newexterns.txt
    echo "url2:link@11456 extname" >>newexterns.txt
    cat newexterns.txt
    svn propset svn:externals . -F newexterns.txt
    

Clean password cache

cd ~/.subversion/auth/svn.simple/ && rm * && cd -
# or
rm $HOME/.subversion/auth

Flow patterns

See also

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment