Ubuntu 26.04

Git : Git-SVN を利用する2026/07/06

 

サーバー側が Subversion リポジトリを使用している場合に、クライアント側で Git-SVN をインストールすると、Subversion リポジトリに対して Git のワーキングリポジトリを作成して利用することができます。

[1] クライアント側で Git-SVN をインストールしておきます。
root@node01:~#
apt -y install git-svn
[2] 当例では Subversion サーバーへ HTTP アクセス可能であることを前提に進めます。(必須ではない)
また Subversion サーバー [dlp.srv.world] 上の [/var/svn/repos/project] リポジトリに対して操作します。
resolute@node01:~$
mkdir work3

resolute@node01:~$
cd work3
# [git svn ***] で SVN リポジトリからクローン

resolute@node01:~/work3$
git svn clone --username ubuntu 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/resolute/work3/project/.git/
Authentication realm: <https://dlp.srv.world:443> DAV SVN
Password for 'ubuntu':
W: +empty_dir: trunk
r1 = e799bd18747b57496d6651fd87264ddb444e8cf8 (refs/remotes/git-svn)
W: +empty_dir: branches
r2 = 9756e6265a8c052fd846d61b6df945aad9d9eb7d (refs/remotes/git-svn)
W: +empty_dir: tags
r3 = 217cb13dc71bdddd04c855ce29228dd53be2c233 (refs/remotes/git-svn)
        A       trunk/index.html
r4 = 7663ea26709c331854367e5376d98863e6f15f2c (refs/remotes/git-svn)
Checked out HEAD:
  https://dlp.srv.world/project r4
creating empty directory: branches
creating empty directory: tags

resolute@node01:~/work3$
total 12
drwxrwxr-x 3 resolute resolute 4096 Jul  6 00:50 ./
drwxr-x--- 7 resolute resolute 4096 Jul  6 00:50 ../
drwxrwxr-x 6 resolute resolute 4096 Jul  6 00:50 project/

resolute@node01:~/work3$
cd project/trunk

resolute@node01:~/work3/project/trunk$
total 12
drwxrwxr-x 2 resolute resolute 4096 Jul  6 00:50 ./
drwxrwxr-x 6 resolute resolute 4096 Jul  6 00:50 ../
-rw-rw-r-- 1 resolute resolute   11 Jul  6 00:50 index.html

# 適当にファイルを更新して 更新したファイルを [commit]

resolute@node01:~/work3/project/trunk$
echo "test file" >> index.html

resolute@node01:~/work3/project/trunk$
git commit index.html -m "update"

[master a595fb1] update
 1 file changed, 1 insertion(+)

# 更新を [push] する場合は [dcommit]

resolute@node01:~/work3/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 'ubuntu':
        M       trunk/index.html
Committed r5
        M       trunk/index.html
r5 = cde56819eb8eb58024383b79e9eb774eeeb8d6d4 (refs/remotes/git-svn)
No changes between a595fb16cbf69a150fae6dfe87f0213cddd0c041 and refs/remotes/git-svn
Resetting to the latest refs/remotes/git-svn

# 他人が更新したファイルを自身のローカルディレクトリにマージする場合は [rebase]

resolute@node01:~/work3/project/trunk$
git svn rebase

Authentication realm: <https://dlp.srv.world:443> DAV SVN
Password for 'ubuntu':
        M       trunk/index.html
r8 = a6a06c30b42bc3b3543cc0206196297644fcf2b0 (refs/remotes/git-svn)
Successfully rebased and updated refs/heads/master.
関連コンテンツ