linux搭建个人git服务器
- 创建
git
用户,设置.ssh
、.ssh/authorized_keys
。 - 创建远程仓库,并且初始化
mkdir project
cd project
mkdir test1_repo.git
cd test1_repo.git
git --bare init # 必须是bare
- 初始化本地仓库
git init
git add .
git commit -m "first push"
- 关联远程仓库并推送
git remote add origin git@$(ip):/home/git/project/test1_repo.git
git push origin master
观察
github
仓库地址:git@github.com:user_name/repo_name.git
我们的仓库地址:git@$(ip):/home/git/project/test1_repo.git