Subversion at the Command Line for Git Users
I love the command line and have experience with
git
. I shied away from
git svn
because it might confuse my team. So here is my list of
svn
usage and commands and their
similar
commands in
git
. This is a work in progress. If anything doesn't seem quite right, please let me know.
Documentation
- svn 1.4 http://svnbook.red-bean.com/en/1.4/svn-book.html
- svn 1.7 http://svnbook.red-bean.com/en/1.7/svn-book.html
Working with remotes
svn checkout <uri>
vs
git clone <uri>; git pull;
svn update -r238
vs
git checkout fder3fd
- checkout a working copy
svn info .
vs
git remote -v
- show the remote uri
- git can have multiple remotes, svn can have only one
svn ls <uri>/branches --verbose
vs
git branch --all -vv
- list details of all branches
- in git this includes local and remote branches
svn switch<uri>/branches/<branch_name>
vs
git checkout <branch_name>
- switch from one branch to another
svn status
vs
git status
Add / commit / push
svn commit -m "Some message"
vs
git commit -m "Some message"; git push
- in subversion, a commit is equivalent to a git commit+push
- also, we don't have to stage tracked items
Fixing mistakes
svn revert foo.txt
vs
git checkout -- foo.txt
svn revert * --recursive
vs
git reset --hard HEAD
- remove all local modifications
- without touching untracked files
Branching and merging
svn copy <url> branches/mybranch
:
git checkout -b mybranch
History
svn log -limit 5
vs
git log -5
svn log --revision 1:HEAD
svn log --stop-on-copy
- determine the ancestor of a branch
- use to figure out with which branch merges are possible
Using PowerShell
@(svn status) -match '^M'
- list only modified files
@(svn status) -match '(^ L)
- list only locked files
@(svn status) -match '^\?' | % { ($_ -split '\?\s*')[1] } | % { ri $_ -force -recurse }
vs
git clean -f -d
- remove all untracked files
- without touching tracked files
-
@(svn status)
wraps the output into an array -
-match '^\?'
filters on lines that start with an?
-
($_ -split '\?\s*')[1]
retrieves just the file or directory
(svn help status)[0..25]
-
Limit the
svn help <command>
output to just the lines you want - for instance, lines zero to 25: