openSUSE Leap 16

Git : Git-SVN を利用する2025/12/24

 

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

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

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

suse@node01:~/work3>
git svn clone --username suse 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>
hint:
hint: Disable this message with "git config set advice.defaultBranchName false"
Initialized empty Git repository in /home/suse/work3/project/.git/
Authentication realm: <https://dlp.srv.world:443> DAV SVN
Password for 'suse':
W: +empty_dir: trunk
r1 = e7fbe8a67a734caab2c790662d7ced18b4180b80 (refs/remotes/git-svn)
W: +empty_dir: branches
r2 = d7f2f12374cf99f51d02a6a6ee22490d6b9831bd (refs/remotes/git-svn)
W: +empty_dir: tags
r3 = 81d7e966f75851c76cb2bf1173e6609af5114ce0 (refs/remotes/git-svn)
        A       trunk/index.html
r4 = 0b2be9f9f794af1681d1bc9faef66687c35465f4 (refs/remotes/git-svn)
Checked out HEAD:
  https://dlp.srv.world/project r4
creating empty directory: branches
creating empty directory: tags

suse@node01:~/work3>
total 0
drwxr-xr-x. 1 suse suse 42 Dec 24 10:55 project

suse@node01:~/work3>
cd project/trunk

suse@node01:~/work3/project/trunk>
total 4
-rw-r--r--. 1 suse suse 11 Dec 24 10:55 index.html

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

suse@node01:~/work3/project/trunk>
echo "test file" >> testfile.txt

suse@node01:~/work3/project/trunk>
git add testfile.txt

suse@node01:~/work3/project/trunk>
git commit testfile.txt -m "add"

[master 7838617] add
 1 file changed, 1 insertion(+)
 create mode 100644 trunk/testfile.txt

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

suse@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 'suse':
        A       trunk/testfile.txt
Committed r6
        A       trunk/testfile.txt
r6 = 11ae82d26e50c419b62bcffb08221cf7c316d45e (refs/remotes/git-svn)
No changes between 783861779ef58c1fbe4c822dedb7c624e1fda8f8 and refs/remotes/git-svn
Resetting to the latest refs/remotes/git-svn

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

suse@node01:~/work3/project/trunk>
git svn rebase

Authentication realm: <https://dlp.srv.world:443> DAV SVN
Password for 'suse':
Current branch master is up to date.
関連コンテンツ