服务端

1
2
3
4
5
#安装
yum -y install git

# 添加仓库
git init --bare sample.git

git bash客户端

1
2
3
4
5
6
7
8
#生成公钥  
ssh-keygen

#导入  
ssh -p port root@host 'mkdir -p .ssh && cat >> ~/.ssh/authorized_keys' < ~/.ssh/id_rsa.pub

# 下载
git clone --depth 1 --recursive ssh://root@server:port/root/sample.git

迁移

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
1.先克隆老项目的镜像  
git clone --mirror old.git (old.git 为老项目的git地址)

2.进入老项目的目录  
cd old.git

3.移除老项目的地址替换成新项目  
git remote set-url --push origin new.git (new.git 为新项目的git地址)

4.将镜像推到远程  
git push --mirror //这一步需要输入新的git的账号和密码