Step 1: Set up the server
First, if you haven’t done so already, add your public key to the server:
ssh user@server.com mkdir .ssh
scp ~/.ssh/id_rsa.pub user@server.com:.ssh/authorized_keys
and then SSH into our server and install Git:
ssh server.com
sudo apt-get update
sudo apt-get install git-core
or you can install git using tar.bz2 or tar.qz file available in http://git-scm.com/
Step 2: Adding a user
So, add a Git user:
sudo adduser git (here "git" is user name of your user account in the Linux machine)
Now you’ll need to add your public key to the Git user’s authorized_keys:
sudo mkdir /home/git/.ssh
sudo cp ~/.ssh/authorized_keys /home/git/.ssh/
sudo chown -R git:git /home/git/.ssh
sudo chmod 700 !$
sudo chmod 600 /home/git/.ssh/*
If this commands not working for you try it to do manually (carefully)
Now you’ll be able to authenticate as the Git user via SSH. Test it out:
ssh git@server.com
Step 3: Add your repositories
If using the Git user, log in as them:
login git
Now we can create our repositories:
mkdir myrepo.git
cd !$
git --bare init (this creates an empty Git repository)
Step 4: Configure your development machine
First, add the remotes to your local machine.
git remote add origin git@server.com/myrepo.git
git push origin master
If you’ve already defined a remote named origin
git remote rm origin
No comments:
Post a Comment