Skip to content

Instantly share code, notes, and snippets.

@o-gh
Last active February 8, 2023 01:21
Show Gist options
  • Save o-gh/8f353f0db0fdd4ccf706fd8b6db0f07c to your computer and use it in GitHub Desktop.
Save o-gh/8f353f0db0fdd4ccf706fd8b6db0f07c to your computer and use it in GitHub Desktop.
WindowsでSubversionをGitと連携させて使う方法

WindowsでSubversionをGitと連携させて使う方法

1.Gitの設定

改行コードが変換されないようにする

git config --global core.autoCRLF false

2.Gitリポジトリの作成

単純なパターン

git svn clone --prefix=svn/ --username=user http://example.jp/svn

SVNの一般的な構造を取り込むパターン

  • SVNのtrunkをGitのmasterブランチに割り当てる
  • SVNのbranchesをGitのブランチにする
  • SVNのtags配下をGitのタグにする

この場合-sオプションを付ける

git svn clone -s --prefix=svn/ --username=user http://example.jp/svn

SVNの独自な構造を取り込むパターン

SVNのtrunkやbranchesやtagsにあたるディレクトリをオプションで直接指定する

git svn clone --trunk release --branches develops --tags var --prefix=svn/ --username=user http://example.jp/svn

3.SVNの除外ファイルをGitに設定する

git svn show-ignore >> .git/info/exclude

4.運用

基本的にGitのmasterブランチをSVNのtrunkとやり取りするのに使うのが単純である。作業ブランチはGitのブランチを使う。

Gitに最新のSVNコミットを取り込む

git checkout master
git svn rebase

Gitのブランチを作成し編集作業

git checkout master
git checkout -b work
git checkout work

SVNのリモートリポジトリへコミット

git checkout master
git svn rebase

git checkout work
git rebase master

git checkout master
git merge --squash work
git commit
git svn dcommit -n
git svn dcommit
git branch -d work
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment