Configure a git server under Mac

Source: Internet
Author: User
Tags python script git clone

One, set up remote access

Logout your current account, log in with your Git account, and in System preferences->sharing, tick: Web sharing and Remote logig.

Two. Download and install Gitosis

1,mac Snow by default, Git and Python have been installed for us, and you can use the following command to view its version information:

yourname:~ git$ git--version

git version 1.7.3.4

yourname:~ git$ python--version

Python 2.6.1

2, by command git clone https://github.com/tv42/gitosis.git

3. Go to the Gitosis directory and use the command "sudo python setup.py install" to execute the Python script installation gitosis.

yourname:~ wei_jingyun$ CD gitosis/

Yourname:gitosis wei_jingyun$ sudo python setup.py install

Running Install

Running Bdist_egg

Running Egg_info

Creating Gitosis.egg-info

......

Using/library/python/2.6/site-packages/setuptools-0.6c9-py2.6.egg

Finished processing dependencies for gitosis==0.2

Three. Making the public key on the client

bash-3.2$ CD ~

bash-3.2$ ssh-keygen-t RSA

The public key can be renamed and copied to the server for ease of administration

Four. Configure the public key on the server to allow it to access

Note:/tmp/yourname.pub is the public key path, you need to copy the client generated public key to the server to fill in the path you can

Yourname:gitosis git$ sudo-h-u git gitosis-init </tmp/yourname.pub

In this case, the client will be treated as a trusted account, so there will be records in the. SSH directory of the user files, and the content of the file Authorized_keys is similar to yourname.pub.

Authorized_keys file with appended public key information

We need to change authorizd_keys slightly, open it with a text editor, delete the "command=" Gitosis-serve yourname ", no-port-forwarding,no-x11-forwarding, No-agent-forwarding,no-pty "This line:

If you want to add the public key information later, if you can not add new in the previous method, we can add the new public key information directly to the

The Authorized_keys file appends a file to another file with the cat command.

localhost:~ wei_jingyun$ cat id_rsa.pub >> Authorized_keys

We then give the post-update a writable permission so that the client can commit the changes. Wei_jingyun needs to replace his own.

localhost:~ wei_jingyun$ sudo chmod 755/users/wei_jingyun/repositories//gitosis-admin.git/hooks/post-update

Password:

localhost:~ wei_jingyun$ CD ~

localhost:~ wei_jingyun$ CD repositories/

localhost:~ wei_jingyun$ ls

Gitosis-admin.git

The last step is to modify the path of the GIT account.

Yourname:gitosis git$ Touch ~/.BASHRC

Yourname:gitosis git$ echo path=/usr/local/bin:/usr/local/git/bin:\ $PATH >. BASHRC

Yourname:gitosis git$ Echo Export PATH >> BASHRC

Yourname:gitosis git$ Cat. BASHRC

Path=/usr/local/bin:/usr/local/git/bin: $PATH

Export PATH

At this point, the configuration of the server is complete.

Five. Configuration of the Client

1, first modify the local git configuration by entering the following command in Terminal:

bash-3.2$ git config--global user.name "This will show who submitted the code"

bash-3.2$ git config--global user.email "must be consistent with the public key last [email protected]"

2, the test server is connected correctly, the 10.1.4.211 is replaced with the name of your service or server address.

yourname:~ local_account$ SSH Host Account (Wei_jingyun) @10.1.4.211

Last Login:mon Nov 7 13:11:38 from 10.1.4.211

3, in the local clone server warehouse, take Gitosis-admin.git as an example:

bash-3.2$ git clone Host Account (Wei_jingyun): Repositories/gitosis-admin.git

Six. How to add new users and new repositories.

    1. Copy the required public key to the Keydir folder.
    2. Open gitosis.conf Add user to Inside

Configure a git server under Mac

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.