CentOS Stream 9
Sponsored Link

Git : Git-SVN を利用する2022/07/21

 
サーバー側が Subversion リポジトリを使用している場合に、クライアント側で Git-SVN をインストールすると、Subversion リポジトリに対して Git のワーキングリポジトリを作成して利用することができます。
[1] クライアント側で Git-SVN をインストールしておきます。
[root@node01 ~]#
dnf -y install git-svn
[2] 当例では Subversion サーバー側で [svnserve] が稼働中であることを前提に進めます。(必須ではない)
また Subversion サーバー [dlp.srv.world] 上の [/var/svn/repos/project] リポジトリに対して操作します。
[redhat@node01 ~]$
mkdir work

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

[redhat@node01 work]$
git svn clone --username cent svn://dlp.srv.world/repos/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/redhat/work/project/.git/
Authentication realm: <svn://dlp.srv.world:3690> 96feb78d-5d30-4dfb-b880-d0c1c719d5e2
Password for 'cent':
W: +empty_dir: trunk
r1 = 9052d23b695fc0646c9345b8b4069e1284b795e6 (refs/remotes/git-svn)
W: +empty_dir: branches
r2 = 0a30039aa7f45879018abb9811d051bd5c0304bc (refs/remotes/git-svn)
W: +empty_dir: tags
r3 = 7ab101e77b94963b5910671b37f74726e7be4b06 (refs/remotes/git-svn)
Checked out HEAD:
  svn://dlp.srv.world/repos/project r3
creating empty directory: branches
creating empty directory: tags
creating empty directory: trunk

[redhat@node01 work]$
total 0
drwxr-xr-x. 6 redhat redhat 59 Jul 21 15:04 project

[redhat@node01 work]$
cd project/trunk

[redhat@node01 trunk]$
total 12
-rw-r--r--. 1 redhat redhat 11 Jul 21 15:12 index.html
-rw-r--r--. 1 redhat redhat 11 Jul 21 15:12 testfile.txt
-rw-r--r--. 1 redhat redhat 11 Jul 21 15:12 test.txt

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

[redhat@node01 trunk]$
echo "test file" >> testfile.txt

[redhat@node01 trunk]$
git commit testfile.txt -m "update"

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

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

[redhat@node01 trunk]$
git svn dcommit

Committing to svn://dlp.srv.world/repos/project ...
        M       trunk/testfile.txt
Committed r6
        M       trunk/testfile.txt
r6 = ec90e44238a2e36c1199c8dc40d10ef966ddd452 (refs/remotes/git-svn)
No changes between efe7dab8400a5322c21c3551dc41772bb41707bd and refs/remotes/git-svn
Resetting to the latest refs/remotes/git-svn

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

[redhat@node01 trunk]$
git svn rebase

        M       trunk/index.html
r7 = 5409bba49db298910223e7dcb8dafcad0932e3b6 (refs/remotes/git-svn)
Successfully rebased and updated refs/heads/master.
関連コンテンツ