SVN備忘録
すっかり忘れてしまっているので、コマンドメモ
コマンド操作
最初のコミットまで
$ cd /tmp $ svnadmin create svnrepo $ cd /path/to/dir $ svn co file:///tmp/svnrepo $ cd svnrepo && mkdir {trunk,branches,tags} $ svn add * $ svn ci -m'inital commit'
branche作成
$ cd /path/to/svnrepo/trunk $ echo 'hoge' > test.txt $ svn add test.txt $ svn ci -m'add: test.txt' $ cd /path/to/svnrepo $ svn cp trunk branches/dev $ svn ci -m 'create new branch, dev'
branche切り替え
$ svn switch file:///tmp/svnrepo/branches/dev /path/to/svnrepo/branches/dev/ $ svn info | grep URL URL: file:///tmp/svnrepo/branches/dev
diff(branch間)
ex) devAブランチとdevBブランチを比較
svn diff file:///tmp/svnrepo/branches/devA file:///tmp/svnrepo/branches/devA
diff結果に色をつける
svn diff | vim -R -
差分のあったファイル名のみ表示
svn diff --summarize
Option(Port, SSH Key)
$ svn commisvn add script $ svn status $ svn commit -m 'comment hogehoge' --config-option "config:tunnels:ssh=ssh -p <Port No> -i /Users/edo/.ssh/<Private Key> -l <Username> -q" -m 'comment hogehoge' $ svn checkout --config-option "config:tunnels:ssh=ssh -p <Port No>-i /Users/edo/.ssh/<Private Key> -l <Username>-q" svn+ssh://edohub.net/ops/build/repo/svnrepo
設定関連
~/.subversion/config
### Section for configuring miscelleneous Subversion options. [miscellany] global-ignores = *.o *.lo *.la *.al .libs *.so *.so.[0-9]* *.a *.pyc *.pyo .*.swp .DS_Store *.bak *.bk *.log *.tmp log-encoding = utf-8 enable-auto-props = yes ### Section for configuring automatic properties. [auto-props] *.sh = svn:eol-style=native;svn:executable *.rb = svn:eol-style=native;svn:executable *.pl = svn:eol-style=native;svn:executable *.py = svn:eol-style=native;svn:executable *.conf = svn:eol-style=native *.sql = svn:eol-style=native *.htm* = svn:eol-style=native *.prop* = svn:eol-style=native *.y*ml = svn:eol-style=native *.json = svn:eol-style=native *.md = svn:eol-style=native *.markdown = svn:eol-style=native
プロンプトにSVNブランチ名表示
コピー元: Add Git and SVN Branch to Bash Prompt - hocuspokus
まんまコピーだと動かなかったので、"parse_svn_repository_root"関数の記載位置を変更した。
parse_svn_repository_root() { svn info 2>/dev/null | sed -ne 's#^Repository Root: ##p' } parse_svn_branch() { parse_svn_url | sed -e 's#^'"$(parse_svn_repository_root)"'##g' | awk '{print " (svn::"$1")" }' } parse_svn_url() { svn info 2>/dev/null | sed -ne 's#^URL: ##p' } BLACK="\[\033[0;38m\]" RED="\[\033[0;31m\]" RED_BOLD="\[\033[01;31m\]" BLUE="\[\033[01;34m\]" GREEN="\[\033[0;32m\]" export PS1="$BLACK[ \u@$RED\h $GREEN\w$RED_BOLD\$(parse_git_branch)\$(parse_svn_branch)$BLACK ] "
svnserve
$ svnserve -d -r /tmp/svnrepo $ sudo netstat -altpn | grep svn ※3690ポートで起動していることを確認 tcp 0 0 0.0.0.0:3690 0.0.0.0:* LISTEN 1397/svnserve $
- "-d" で、デーモン指定
- "-r" レポジトリのルートを指定
Hook
名前 | 実行タイミング | 用途 |
---|---|---|
pre-commit | コミット前 | 前提条件チェックなどで不正コミット拒否など |
post-commit | コミット後 | 通知処理など |
$ cp /tmp/svnrepo/hooks/post-commit.tmpl /tmp/svnrepo/hooks/post-commit
TortoiseSVN
- 差分表示(ブランチ間) Shiftを押しながら右クリック 差分の表示