At times we’ll need to create a git repository and put is to a server where other developers can access. Of course you can do it with github or other git repository hosting service, but what if you’ll need to put it to your own server?

1. Create git directory locally

1.a to make your current directory a git repository, enter the command,

git init

1.b to make a directory a git repository, enter the command,

git init <directory name>

After initialization the git repository, you can add some files. If the repository is empty when you publish to server, it’ll more troublesome to configure.

2. Add new files

git add <project files and folders>
git commit -am “check in msg”

3. Publish repository to server

git clone <directory path>/<directory name> <project name>.git
scp -r <project name>.git <ssh username>@<ssh server address>:<your git server path>

4. Commit changes to server

git push <ssh username>@<ssh server address>:<your git server path>/<project name>.git

or simply

git push

5. Clone the project

git clone <ssh username>@<ssh server address>:<your git server path>/<project name>.git

6. Get Changes

git pull <ssh username>@<ssh server address>:<your git server path>/<project name>.git

or simply

git pull

 

One comment on “Publish Git Repository to Server

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Set your Twitter account name in your settings to use the TwitterBar Section.