文章目录
- 创建git用户 groupadd git useradd git -g git 服务器禁用shell登录 vim /etc/passwd git:x:1004:1004::/home/git:/usr/bin/git-shell 设定仓库路径 mkdir -p /home/git-repro/git 创建裸仓库 cd /home/git-repro/git git init --bare code.git
- 创建私钥 ssh-keygen -t rsa 查看本地私钥 more id_rsa.pub 把私钥放到服务器上 vim authorized_keys 克隆服务器端仓库 git clone ssh://ssh账号名@域名或者服务器ip:ssh端口号 仓库地址 git clone ssh://[email protected]:9097/home/git-repro/git/code.git 其它都和常用git操作一样了 echo "test" >> test.py git add . git commit -m 'First commit' git push
- https://eyunzhu.com/1858 git 内部存储原理参考
本教程适合对git有一定熟悉能力的人,不熟悉的建议先去用用Github。这里适合个人用户使用,如果是团队或企业用户建议去用更成熟的Gitea或其它产品。
- 创建git用户
groupadd git
useradd git -g git
- 服务器禁用shell登录
vim /etc/passwd
git:x:1004:1004::/home/git:/usr/bin/git-shell
- 设定仓库路径
mkdir -p /home/git-repro/git
- 创建裸仓库
cd /home/git-repro/git
git init --bare code.git
groupadd git
useradd git -g git
vim /etc/passwd
git:x:1004:1004::/home/git:/usr/bin/git-shell
mkdir -p /home/git-repro/git
cd /home/git-repro/git
git init --bare code.git
- 创建私钥
ssh-keygen -t rsa
ssh-keygen -t rsa

- 查看本地私钥
more id_rsa.pub
- 把私钥放到服务器上
vim authorized_keys
- 克隆服务器端仓库
git clone ssh://ssh账号名@域名或者服务器ip:ssh端口号 仓库地址
git clone ssh://[email protected]:9097/home/git-repro/git/code.git
- 其它都和常用git操作一样了
echo "test" >> test.py
git add .
git commit -m 'First commit'
git push
-
这个问题一般前面git commit -m 'First commit'有相关报错,如下图:

-
按提示操作即可
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
这个问题一般前面git commit -m 'First commit'有相关报错,如下图:

按提示操作即可
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
