Use repo + gitolite to manage your own code

Source: Internet
Author: User
Tags git client

Install gitolite and download repo

Repo should be placed under/usr/local/bin.

Then use gitolite-admin.git for management

The conf file is the permission management file, and the keydir file contains various keys.

Ssh keys are generated using sshkey-gen, and the public key of xxx. pub is used.

A git user can be created separately and configured to have no shell, and cannot be logged on directly. Every time you use sudo su-git to switch users

Then, you can create a repository, xxx. git, and various. git repositories.

Then initialize git -- bare init for each repository.

Use the following script to initialize

#/Bin/bash #$0 is the name of the currently running program #$1 is the first input parameter # The first parameter is the directory name, all directories under it to be traversed # echo "\ $1:" $1 function scandir () {local cur_dir parent_dir workdirworkdir = $ 1cd $ {workdir} if [$ {workdir} = "/"] then cur_dir = "" elsecur_dir = $ (pwd) required or dirlist in $ (ls $ {cur_dir}) do # echo $ {dirlist} fileCount =$ (ls $ {dirlist} | wc-l) if [$ {fileCount}-gt "0"] then # This directory has been initialized with cd $ {dirlist} cd .. else # This directory is empty cd $ {dirlist} git -- bare initcd .. fidone} If test-d $1 then scandir $1 elif test-f $1 then echo "you input a file but not a directory, pls reinput and try again "exit 1 else echo" the Directory isn' t exist which you input, pls input a new one !! "Exit 1fi

To use repo, you need a manifest. git to manage the project.

Put a default. xml file in it

<?xml version="1.0" encoding="UTF-8"?>   <manifest>           <remote name="xxx"                   fetch=".."/>           <default revision="xxx" remote="xxx"/>           <project path="xxx" name="xxx/xxx"/>  </manifest>

Path refers to the path stored after download, and name refers to the path of the code repository on the server.

Use the following command when downloading with repo:

#! /bin/bashfunction download_gits() {repo init -u git@localhost:/androidMSTAR/manifest.git -b master#repo init -u git@www.yangyang.com:/androidMSTAR/manifest.git -b masterrepo syncrepo forall -c git checkout -b master}

Download manifest first, and then download the repositories described in manifest.

After the download is complete, use repo forall to perform branch switching for all databases.

The basic process is like this. I think the script can be further optimized and more powerful.

==== Update ====

If the code is changed, for example, a new directory is added.

You need to change the location

First, initialize the new xxx. git on the git client mkdir and then git -- bare init.

Then add the corresponding entries to manifest.

Add the library name and corresponding permissions to the conf file in gitolite-admin.

Find a location and clone it to an empty directory.

Copy the file

Git add./git commit-asm 'xxx'/git push

Submit the new code in this way.

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.