Setting up a remote git server using ssh

Category : How to, Programming

Hello,

This is how to set up a remote git server using ssh.

First of all, install git in your machine and also on the server. Then, you have to setup the server by doing the following:

Setting Up the server:

1
2
3
mkdir /path/to/your/desired/repository.git
cd /path/to/your/desired/repository.git
git --bare init

Simple as this. And you are done in the server side. Now go to your local machine e start using Git.

Set up your application to use git

1
2
3
4
cd /path/to/your/application
git init
git add
git commit -m 'first commit'

After doing it, you are already using git, but locally, to send your files to the server, do the following:

Committing from your local repository to your server

1
2
git remote add origin git@REMOTE_SERVER:/path/to/your/desired/repository.git
git push origin master

And that’s it, now you have your server and your machine working together.

Now, have a look at a few basic commands:

Git basic commands

To checkout (svn/cvs “language”) your files:

1
git clone url

To update your local repository with the remote files:

1
git pull

To commit your files to your local repository:

1
git commit -a

To commit your files to your remote repository:

1
git push

To see the difference from modified files to the files in the repository:

1
git diff

To check the status of you files:

1
git status

To check logs

1
git log

or

1
git blame file

Enjoy ;)

Popularity: 2% [?]