Use EC2 to create a private git Server

Source: Internet
Author: User

There have been many articles about the Amazon EC2 service, so I will not go into details about how to apply for the Amazon cloud service here. Assume that you already have an EC2 server. In addition, applications such as gitosis or gitolite are not used here. EC2 is mainly used as a personal git server through SSH. Amazon offers a free one-year discount for EC2 of the micro type.

To simplify access to the remote host, perform simple SSH Configuration:

$ Cat ~ /. Ssh/config
Host codingme.com
Hostname codingme.com
User ec2-user
Identityfile/path/to/Your/private key file

Because my host has applied for a dynamic IP address and has been bound to my own domain name, you can directly use the domain name address provided by EC2 for each host for the personal domain name used by the hostname above.

In addition, in the configuration fileHost codingme.comIs to specify a host alias, you can write host cm or other easy-to-remember names.

Based on the above configuration, you can easily connect to the host, which is also required to remotely access the GIT repository through SSH-because access to the EC2 host uses the private key, when git accesses a remote repository through SSH, the private key must be used through the above configuration.

1. Create a repository on the remote host

SSH mkdir "> codingme.com
User @ EC2> mkdir-P git/repos/codingme
User @ EC2> Cd git/repos/codingme
User @ EC2> git init -- bare

Pay attention to the above operations and you will find that after using the previous config, you no longer need to specify the private key file and user name to connect to the host through SSH. In addition, if your host alias

2. synchronize data on the remote host

Clone data from a remote host.

Git clone SSH: // codingme.com/home/user/git/repos/codingme

3. Add the repository to an existing local repository.

If your project has been built, it may be hosted in a repository such as GitHub, or you can add a new repository.

Git remote add codingme SSH: // codingme.com/home/user/git/repos/codingme
Git pull codingme master // pull the latest data
Git push codingme master // upload the local data

Note: The codingme.com used in the preceding three steps is the host alias in. Ssh/config, rather than the real host domain name.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.