在共享主机上搭建git服务

GitHub
is awesome, really awesome for open source projects and for projects with multiple people. In
fact, if you use your own git setup for an open source project, you are
most likely hindering your project’s progress and wasting your time.
       
On
the other side of the coin, if you are a lone shark and you don’t need
GitHub’s awesome social features, I have news for you: you can host
your own git repositories really easily and on the cheap side.
        Remote Setup
       
If
you are like me, you probably have a DreamHost, TextDrive or some other
cheap shared hosting account with ssh access. What you might not know
is that is all you need to host your own private git repositories.
ssh username@yourcheaphost.com
mkdir -p ~/git/yourproject.git
cd ~/git/yourproject.git
git --bare init
       
That
is it. Your git repository is now setup. Not too hard eh? You could put
that anywhere but a folder named git makes sense to me.
        Local Setup
       
So
your remote server is now setup, but how do you use it? Glad you asked.
Open up a new tab (or window) or quit your ssh connection and cd to
wherever you want to setup your project locally.
mkdir yourproject
cd yourproject
git init
git remote add origin ssh://username@yourcheaphost.com/~/git/yourproject.git
touch .gitignore
git add .
git commit -m "Initial Commit"
git push origin master
       
At this point you have now pushed to your remote
repository and are almost good to go. The last thing is you need to add
the following on your local machine to .git/config in your project.
[branch "master"]
  remote = origin
  merge = refs/heads/master
        The End
       
That
is it. You can now push and pull at will. If you want to give anyone
else commit access, just add their ssh key to ~/.ssh/authorized_keys
and you can work on the project with a friend. Setting up your own git repositories is really easy, as you can see, so don’t be afraid.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值