Setup Git Server, and Migrate SVN


  1. Create git repository in server side
  2. Basic HTTP Authentication
  3. Migrate SVN to Git repository

Notes: CentOS 6.2, Git Client: SourceTree, Github clinet

Create git repository in server side

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# 1. Install git-core
yum install git-core

# 2. create git account in system
sudo useradd git
sudo usermod -a -G git ${user_account}

# 3. Init repository in server side
GIT_REPOS=/var/git/repos
sudo mkdir -p $GIT_REPOS
sudo chgrp -R git $GIT_REPOS

sudo mkdir -p $GIT_REPOS/{new_project}
cd $GIT_REPOS/{new_project}
git --bare init
git update-server-info

# 4. Test in client side via ssh
cd ${project_path}
git init
# The end of slash is required.
git remote add origin ssh://${user_account}@${server_location/${GIT_REPOS}/${new_project}/

echo "test" > README.md
git add README.md
git commit -m "init" README.md
git push origin master

Basic HTTP Authentication

  1. create account-list file by htpasswd -c account-list git-admin
  2. create group: echo "admin: git-admin" > htgroup
  3. add /etc/httpd/conf.d/git.conf, such as below:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
SetEnv GIT_PROJECT_ROOT /var/git/repos
SetEnv GIT_HTTP_EXPORT_ALL
ScriptAlias /git/ /usr/libexec/git-core/git-http-backend/

<Location /git/>
AuthType Basic
AuthName "Git Access"
AuthUserFile /var/git/conf/account-list
AuthGroupFile /var/git/conf/htgroup

<LimitExcept PROPFIND>
Require valid-user
</LimitExcept>

</Location>

<Location /git/iOS.git>
<LimitExcept PROPFIND>
Require group admin iOS
</LimitExcept>
</Location>

<Location /git/Android.git>
<LimitExcept PROPFIND>
Require group admin Android
</LimitExcept>
</Location>

Migrate SVN to Git repository

Tools: subgit

1
2
3
4
5
6
7
8
9
10
# 1. dump svn to git repository with subgit
SVN_URL="http://svn.company.com/svn/iOS/"
# domain will be as user's email
DOMAIN={company.com}

$ ./subgit import --non-interactive --default-domain ${DOMAIN} --svn-url $url"

# 2. push to git server
$ git push --mirror http://git.company.com/git/iOS.git

Relevant Documents

Reference



Comments

  • 全站索引
  • 關於這裏
  • 關於作者
  • 學習法則
  • 思考本質
  • 一些領悟
  • 分類哲學
  • ▲ TOP ▲