Moon Light Box

Time is Money

Posts match “ git ” tag:

Git - Install Git Server in Synology DS214 NAS

| Comments

Synology DS214 NAS is provided Git server package.

And I noted the setup below.

Click Control Panel.

Create a new user account. (Example : git)

Create a new shared folder. (Example : Repository)

Select user git and on click Read/Write permission.

Click Package Center and install Git Server package.

Launch Git Server and allow user git to use.

Enable SSH srvices then save and reboot.

You need login NAS with root via ssh.
(Linux can use ssh command and Windows can use putty.)

$ ssh -l root # is example. You need find your NAS local area IP.

$ Enter root password

$ cd /volume1/Repository/

$ mkdir moonlightbox.git

$ cd moonlightbox.git

$ git --bare init

$ cd ..

$ chown -R git:users moonlightbox.git

$ exit

Next, we will download moonlightbox project.

$ cd ~

$ git clone ssh://git@

$ Enter git password # In this step, you can see the empty moonlightbox project.

$ cd moonlightbox

$ echo 1 > test.txt

$ git add .

$ git commit -m "Init test"

$ git push origin master

$ Enter git password # Finish check in "Init test" patch into git server.

HaHa. Done! :))))

Linux - Install Gerrit in CentOS 7

| Comments

Step 1. Set Mysql Gerrit Account

# mysql -u root -p

CREATE USER 'gerrit2'@'localhost' IDENTIFIED BY 'secret';
SET PASSWORD FOR 'gerrit2'@'localhost' = PASSWORD('XXXXXX'); // your password
GRANT ALL ON reviewdb.* TO 'gerrit2'@'localhost';


Step 2. Add gerrit2 User.

# sudo useradd -m gerrit2

Step 3. Install Gerrit

# su - gerrit2
# wget
# java -jar gerrit-2.12.war init -d /home/gerrit2/gerrit

Create '/home/gerrit2/gerrit'  [Y/n]? Y
Location of Git repositories   [git]:ENTER
Database server type           [h2]: mysql
Gerrit Code Review is not shipped with MySQL Connector/J 5.1.21
**  This library is required for your configuration. **
Download and install it now [Y/n]?Y
Server hostname                [localhost]:
Server port                    [(mysql default)]:
Database name                  [reviewdb]:
Database username              [gerrit2]:
gerrit2's password             :
              confirm password :
Type                           [LUCENE/?]: ENTER
Authentication method          [OPENID/?]: http
Get username from custom HTTP header [y/N]? N
SSO logout URL                 :ENTER
Enable signed push support     [y/N]? N
Install Verified label         [y/N]? ENTER
SMTP server hostname           [localhost]: ENTER
SMTP server port               [(default)]: ENTER
SMTP encryption                [NONE/?]: ENTER
SMTP username                  : ENTER
Run as                         [gerrit2]:
Java runtime                   [/usr/lib/jvm/java-1.8.0-openjdk-]: ENTER
Copy gerrit-2.12.war to /home/gerrit2/gerrit/bin/gerrit.war [Y/n]? y
Listen on address              [*]: ENTER
Listen on port                 [29418]: ENTER
Download and install it now [Y/n]? y
Behind reverse proxy           [y/N]? y
Proxy uses SSL (https://)      [y/N]? N
Subdirectory on proxy server   [/]: ENTER
Listen on address              [*]: ENTER
Listen on port                 [8081]: ENTER
Canonical URL                  [http://localhost/]:   // change to your IP
Install plugin singleusergroup version v2.12 [y/N]? y
Install plugin commit-message-length-validator version v2.12 [y/N]? y
Install plugin reviewnotes version v2.12 [y/N]? y
Install plugin replication version v2.12 [y/N]? y
Install plugin download-commands version v2.12 [y/N]? y

Step 4. Checked and Modified gerrit.config Configuration

## vim  /home/gerrit2/gerrit/etc/gerrit.config
        basePath = git
        canonicalWebUrl =  // change to your IP
        type = mysql
        hostname = localhost
        database = reviewdb
        username = gerrit2
        type = LUCENE
        type = HTTP
        enableSignedPush = false
        smtpServer = localhost
        user = gerrit2
        javaHome = /usr/lib/jvm/java-1.8.0-openjdk-
        listenAddress = *:29418
        listenUrl = proxy-http://*:8081/
        directory = cache
# java -jar gerrit-2.12.war reindex -d /home/gerrit2/gerrit
# /home/gerrit2/gerrit/bin/ start

Step 5. Install Apache

# sudo yum install httpd httpd-tools openssl mod_ssl
# sudo vim /etc/httpd/conf/httpd.conf
ServerName  // change to your IP
# sudo vim /etc/httpd/conf.d/options.conf

TraceEnable off

## Disable Signature
ServerSignature Off

## Disable Banner
ServerTokens Prod
# sudo vim /etc/httpd/conf.d/vhosts.conf

# Load my vhosts
IncludeOptional vhosts.d/*.conf
# sudo mkdir /etc/httpd/vhosts.d
# sudo systemctl restart httpd
# sudo systemctl status httpd
# sudo systemctl enable httpd

Step 6. Set Apache Proxy

# sudo vim /etc/httpd/vhosts.d/gerrit.conf

<VirtualHost> // change to your IP
    ServerName   // change to your IP

    ProxyRequests Off
    ProxyVia Off
    ProxyPreserveHost On

    <Proxy *>
            Order deny,allow
            Allow from all

    <Location /login/>
            AuthType Basic
            AuthName "Gerrit Code Review"
            Require valid-user
            AuthUserFile '/etc/httpd/gerrit.htpasswd'

    AllowEncodedSlashes On
    ProxyPass / nocanon  // change to your IP

Step 7. Create Gerrit Account

# sudo chmod 755 /home/gerrit2
# sudo htpasswd -c /home/gerrit2/gerrit.htpasswd admin  // the first account is gerrit administrator

New password:
Re-type new password:
Adding password for user admin


Git - Useful Settings

| Comments

# git config --global "Johnny Chu"
# git config --global ""
# git config --global color.diff auto
# git config --global color.status auto
# git config --global color.branch auto
# git config --global color.log auto
# git config --global core.autocrlf false
# git config --global core.whitespace trailing-space,spacebefore-tab,indent-with-non-tab