在服务器上创建git远程仓库

有时自己的代码比较私密,不方便放在github或者其他托管网站,如果你有一个vps的话,可以使用下面这个方法创建一个仓库:

远程:

cd /srv
git init --bare [repo-name].git

本地:

这里其实是使用ssh连接,如果你没改过ssh的端口,[remote-port]则可以省略

git remote add origin root@[remote-ip]:[remote-port]/srv/[repo-name].git
# 这样就添加好了,试试push吧
git push origin master

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注