Git server gitosis installation configuration and how to use Gitignore

Source: Internet
Author: User
Tags openssh server

git server gitosis installation settings

1. Install OpenSSH server

sudo apt-get install openssh-server openssh-client

2. Create a personal public key and private key

Under the default user's home directory path, run the following command to follow the prompts to create the public and private keys

SSH-KEYGEN-T RSA

Generate 2048-bit by default, or you can create a public and private key by using the following command if you need to increase the security level

Ssh-keygen-t rsa-b 4096

By default, the public and private keys are saved in the ~/.ssh directory, as follows:

Id_rsa id_rsa.pub known_hosts

3. Install the GIT server

sudo apt-get install Git-core

4. Configure the GIT server

Create a GIT server administrative user


sudo useradd-m git
sudo passwd git

Create a git repository storage directory

sudo mkdir/home/git/repositories

Set git repository permissions


sudo chown git:git/home/git/repositories
sudo chmod 755/home/git/repositories

Initialize Global Settings


git config--global user.name "myname"
git config--global user.email "[Email protected]"

5. Install Python Setup Tool

sudo apt-get install Python-setuptools

6. Get and install Gitosis


Cd/tmp
git clone https://github.com/res0nat0r/gitosis.git
CD gitosis
sudo python setup.py install

7, Configuration Gitosis


CP ~/.ssh/id_rsa.pub/tmp
Sudo-h-u git gitosis-init </tmp/id_rsa.pub
sudo chmod 755/home/git/repositories/gitosis-admin.git/hooks/post-update

8, Management gitosis configuration


CD ~
git clone [email protected]: User name/gitosis-admin.git
CD gitosis-admin/

After each user generates their own SSH public key file according to the previously mentioned method, the server administrator takes all of the SSH public key files and copies them to the Keydir directory.

Modify the gitosis.conf file as follows


[Gitosis]
[Group Gitosis-admin]
writable = Gitosis-admin
Members = [email protected]
[Group developers]
writable = HelloWorld
Members = [email protected] [email protected]
[Group Test]
readonly = HelloWorld
Members = [email protected]

This configuration file expresses the following meanings: The Gitosis-admin group member has a, the group has read and write permission to the Gitosis-admin warehouse, the developers group has a A, B two members, the group has read and write permission to the HelloWorld Warehouse; the test group has a C member, Have read-only access to the HelloWorld repository. Of course, these configuration files are currently modified only on your local, you must push to gitserver to really take effect. Add a new file, commit and push to a git server:


git Add.
Git commit-am "Add HelloWorld Project and users"
Git remote add Origin ssh://[email Protected]/helloworld.git
Git push Origin Master

9, installation Apache2

sudo apt-get install apache2

10, installation Gitweb

sudo apt-get install Gitweb

11, Configuration Gitweb

By default, no CSS is loaded, and the static files Gitweb to use are connected to DocumentRoot:


cd/var/www/
sudo ln-s/usr/share/gitweb/*.

To modify the configuration:

sudo vi/etc/gitweb.conf

Change the $projectroot to a git repository store directory (for example:/home/git/repositories) and refresh the browser after saving.

If the item is not found, you will need to change the $projectroot/*.git property to 755, allowing Apache users to have Read permissions. You can just change the git that you need to get someone else to access through the Web. http://localhost/cgi-bin/gitweb.cgi


Modify/etc/gitweb.conf Content:


# Path to git projects (<project>.git)
# $projectroot = "/var/cache/git";
$projectroot = "/home/git/repositories";
# directory to use for temp files
$git _temp = "/tmp";
# Target of the home link on top of all pages
$home _link = $my _uri | | "/";
# HTML text to include at home page
$home _text = "indextext.html";
# file with Project list; By default, simply scan the Projectroot dir.
$projects _list = $projectroot;
# stylesheet to use
@stylesheets = ("/gitweb/static/gitweb.css");
# JavaScript code for Gitweb
$javascript = "Gitweb/static/gitweb.js";
# logo to use
$logo = "/gitweb/static/git-logo.png";
# the ' Favicon '
$favicon = "/gitweb/static/git-favicon.png";
# Git-diff-tree (1) options to use for generated patches
# @diff_opts = ("-M");
@diff_opts = ();

12, Configuration Apache2

Ubuntu Default Web Directory is/var/www, the default CGI directory is/usr/lib/cgi-bin/, after the installation is completed Gitweb, Gitweb gitweb.cgi will be automatically placed in the directory.

If your CGI path is not the default/usr/lib/cgi-bin/, you need to copy the gitweb.cgi Gitweb installed in/usr/lib/cgi-bin to the original configured Cgi-bin path and the Apache configuration file/etc/ Add the following at the end of the apache2/apache.conf:


SETENV gitweb_config/etc/gitweb.conf
<directory "/srv/www/cgi-bin/gitweb" >
Options FollowSymLinks execcgi
Allow from all
AllowOverride All
Order Allow,deny
<files gitweb.cgi>
SetHandler Cgi-script
</Files>
Rewriteengine on
Rewritecond%{request_filename}!-f
Rewritecond%{request_filename}!-d
Rewriterule ^.*/gitweb.cgi/$0 [l,pt]
</Directory>

Git uses Gitignore to establish project filtering rules
In the process of collaborative development of code management, you will often encounter some temporary files, configuration files, or generated files, which are different depending on the development side, if you use git Add. By incorporating all the files into the Git repository, there are frequent changes and push, which can be inconvenient for development.

Git can easily help us solve this problem, that is, the establishment of the project file filtering rules.

There are two filtering mechanisms available in Git, one is the global filtering mechanism, which applies to all git, and the other is the filtering rules that are used for an item. Individuals tend to the second kind.

As an example of one of my projects, the project uses. NET development,. config files, including generated Bin/debug, bin/release files, and so on, I hope not to join Git management.

In the code directory, create the. gitignore file: Vim. Gitignore, as follows:


#过滤数据库文件, SLN solution files, configuration files
*.mdb
*.ldb
*.sln
*.config


#过滤文件夹Debug, Release,obj
debug/
release/
obj/

Then call git Add. , execute git commit.

Git server gitosis installation configuration and how to use Gitignore

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.