bare 仓库(裸仓库):
通常命名为:
xxx.git
ssh user@your.remote.host
(如果 SSH 用的是非 22 端口):
ssh -p 2222 user@your.remote.host
mkdir -p ~/git/myproject.git
cd ~/git/myproject.git
git init --bare
git remote add origin ssh://user@your.remote.host:2222/home/user/git/myproject.git
或使用 SSH config(推荐):
Host myserver
HostName your.remote.host
Port 2222
User user
git remote add origin myserver:/home/user/git/myproject.git
git push -u origin main
列出文件:
git --git-dir=~/git/myproject.git ls-tree -r main
查看文件内容:
git --git-dir=~/git/myproject.git show main:README.md
git clone ~/git/myproject.git ~/checkout/myproject