Git : Git-SVN を利用する2026/02/12 |
|
サーバー側が Subversion リポジトリを使用している場合に、クライアント側で Git-SVN をインストールすると、Subversion リポジトリに対して Git のワーキングリポジトリを作成して利用することができます。 |
|
| [1] | クライアント側で Git-SVN をインストールしておきます。 |
|
root@node01:~ # pkg install -y git-svn
|
| [2] | 当例では Subversion サーバー側で HTTP アクセス可能なリポジトリを設定していることを前提に進めます。 また Subversion サーバー [dlp.srv.world] 上の [/home/svn/repos/project] リポジトリに対して操作します。 |
|
freebsd@node01:~ $
mkdir work freebsd@node01:~ $ cd work
# [git svn ***] で SVN リポジトリからクローン freebsd@node01:~/work $ git svn clone --username freebsd https://dlp.srv.world/project
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint:
hint: git config --global init.defaultBranch <name>
hint:
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint:
hint: git branch -m <name>
Initialized empty Git repository in /home/freebsd/work/project/.git/
Authentication realm: <https://dlp.srv.world:443> DAV SVN
Password for 'freebsd':
W: +empty_dir: trunk
r1 = 1145004092d7fb8c974ef45e1e4b43a4e1650d5c (refs/remotes/git-svn)
W: +empty_dir: branches
r2 = 5360b0246ff63a107a05ede4aae34344766b324c (refs/remotes/git-svn)
W: +empty_dir: tags
r3 = 1eddcdbd9f5422248296e8f6615a4b3581978e5d (refs/remotes/git-svn)
A trunk/index.html
r4 = cb6f661f3371f2079e368dbb78500b89e83f92e1 (refs/remotes/git-svn)
Checked out HEAD:
https://dlp.srv.world/project r4
creating empty directory: branches
creating empty directory: tags
freebsd@node01:~/work $ ls -l total 1 drwxr-xr-x 6 freebsd freebsd 6 Feb 12 09:52 projectfreebsd@node01:~/work $ cd project/trunk freebsd@node01:~/work/project/trunk $ ls -l total 1 -rw-r--r-- 1 freebsd freebsd 22 Feb 12 09:52 index.html # 適当にファイルを更新して 更新したファイルを [commit] freebsd@node01:~/work/project/trunk $ echo "test file" >> index.html freebsd@node01:~/work/project/trunk $ git commit index.html -m "update" [master 86cdafb] update 1 file changed, 1 insertion(+) # 更新を [push] する場合は [dcommit] freebsd@node01:~/work/project/trunk $ git svn dcommit
Duplicate specification "id|i=s" for option "i"
Committing to https://dlp.srv.world/project ...
Authentication realm: <https://dlp.srv.world:443> DAV SVN
Password for 'freebsd':
M trunk/index.html
Committed r5
M trunk/index.html
r5 = 8f7381dea6710baeea717048d1c2ec019e335caf (refs/remotes/git-svn)
No changes between 86cdafb4797dffa9ec1f89a9feca73702dc8be74 and refs/remotes/git-svn
Resetting to the latest refs/remotes/git-svn
# 他人が更新したファイルを自身のローカルディレクトリにマージする場合は [rebase] freebsd@node01:~/work/project/trunk $ git svn rebase
Authentication realm: <svn://dlp.srv.world:3690> 84792bc8-15d0-4409-8573-be73eacd8478
Password for 'ubuntu':
M trunk/index.html
r8 = a6a06c30b42bc3b3543cc0206196297644fcf2b0 (refs/remotes/git-svn)
Successfully rebased and updated refs/heads/master.
|
| Sponsored Link |