Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Server \ Build your own Git server under Linux     - Linux performance optimization features Tuned and ktune (Linux)

- Vim plugin installation YouCompleteMe (Linux)

- UNIX and class UNIX system security check notes (Linux)

- Oracle user password problem (Database)

- wget command examples (Linux)

- MySQL service failed to start thinking of settlement under CentOS7 (Database)

- Linux System shutdown procedures (Linux)

- SELinux multi-level security (Linux)

- Bash environment is automatically install and initialize oh-my-zsh & autojump zsh (Linux)

- MySQL simple operation notes under Linux (Database)

- Dell R710 server disk recovery database one case (record) (Server)

- The mv command to move the directory two cases under Linux (Linux)

- Linux Security and Optimization (Linux)

- Use CutyCapt to convert HTML pages to png images on Linux (Linux)

- The temporary operation of the document mkstemp on Linux (Linux)

- Linux AS4 VPN server in conjunction with a firewall perfect (Linux)

- Java recognize simple codes (Programming)

- AngularJS - Custom instructions (Programming)

- Why do I prefer Git (Linux)

- Linux performance monitoring and common commands Introduction (Linux)

  Build your own Git server under Linux
  Add Date : 2018-11-21      
  Linux set up under their own Git server, get a long time and finally get, or the next record it, or something next time forgot.



Construction git directory

git user, git group as a warehouse management
ssh authorization (remote access without a password)
hook (post-receive) code to automatically deploy Web Directory
Web Directory

Ready to take on the line of code

Setting up development directory
ssh connection key generation
git operations. . .
Began to implement it!

First git source compiler


Download the latest version git (.gz) to / usr / local


tar -zxf git-2.2.1.tar.gz
cd git.2.2.1
make prefix = / usr / local / git all
make prefix = / usr / local / git install
Source compiler is not as easy yum install git-all, but versions can update point, I used the Ali CentOS6.5, corresponding only to the git version 1.7.2

Git does not own equipment in the system PATH environment by modifying / etc / profile method manually paste

vim / etc / profile
# Find PATH = / usr / local / php / bin: $ PATH line to modify
PATH = / usr / local / php / bin: / usr / local / git / bin: $ PATH
# Save and exit shell reconnect it goes into effect
git repository

groupadd git
useradd git -g git
cd / home / git
mkdir repo.git # Name Custom
cd repo.git
git init --bare # generation bare warehouse, storage version information in addition to the code
chown -R git: git /home/git/repo.git
One thing to note here, online promising security reasons, only connect to git git-shell to enable users of ssh, source installation required as follows

# Modify / etc / passwd
vim / etc / passwd
# Find git user settings such as:
git: x: 502: 503 :: / home / newbmiao: / bin / bash # last path to an executable file
git: x: 502: 503 :: / home / git: / usr / local / git / bin / git-shell # bin directory in the installation package
# To enable the needed source reported git-shell command interaction
cp /usr/local/git-2.2.1/contrib/git-shell-commands / home / git /
# After git account so that users can only use the git ssh connection commands
Free connection ssh password authentication

su git # switch git status
cd / home / git /
ssh-keygen -C 'your@email.com' -t rsa # generate rsa key for you, you can directly enter all the way, the default action
Client generates close to way above.
After generating a key will appear

  id_rsa.pub # public service side need to verify the connection with the identity of the contents inside
On the client, open id_rsa.pub copy the contents inside

vim /home/git/.ssh/authorized_keys
# Paste client-generated public key, save and exit
# To start sshd and then git-daemon
/etc/init.d/git-daemon restart
# Top git-daemon in the installation directory / usr / local / git / libexec / git-core / git-daemon, copied directly past trip
/etc/init.d/sshd start
Such server side git repository on setting up the

Client git development

The client (the author is a window of git bash) git operations submitted try

# Enter an empty working directory
initialize git git init #
vim test
# Save and exit edit some content
git add test # added to git cache
git commit -m 'init test' # submit modifications
# Add a remote git repository
git remote add origin git @ your_host_name: /home/git/repo.git
git push origin master # This will sync to the server
Other people want to synchronize

# Clone and push:
git clone git @ your_host_name: /home/git/repo.git
cd repo
git commit -am 'fix for the README file'
git push origin master
Code synchronization (HOOK)
It used to make the top git version control center
But also we want to modify the server after receiving the update automatically synchronized code to your site directory, easy to test development
Can be achieved as follows

# Assumes that the website directory / www / web under
cd /home/git/repo.git/hooks
vim post-receive # Create a hook
# Write the following content
GIT_WORK_TREE = / www / web git checkout -f
# Save and exit
chown git: git post-receive
chmod + x post-receive
So, next time to commit changes, the code will be automatically synchronized to the specified directory

But at the beginning I still can not solve a problem encountered is that ssh public key to the server, and also start git-daemon sshd, the client git clone actually have a password, and after entering the password prompt Permission denied, please try again .

But behind the bizarre it might be permissions change, do not know why, particularly tight connection process ssh how Free.
- Ubuntu 14.10 / 14.04 / 12.04 How to install Kodi 14.0 RC3 (Linux)
- Ubuntu Locale configuration problem solving Can not set LC_CTYPE (Linux)
- Install Oracle database error process of [INS-35172] (Database)
- Oracle GoldenGate encryption (Database)
- Unity Greeter Badges: the lost session icon back to the login screen Ubuntu (Linux)
- Java method to read and write files summary (Programming)
- Java Foundation - Getting Start (Programming)
- Monitor log file (listener.log) (Database)
- secureCRT remote login Linux must first open the connection protocol (Linux)
- Spring Data JPA call a stored procedure examples (Programming)
- Linux Getting Started tutorial: Experience Xen Virtual Machine chapter (Linux)
- CentOS 6 / Linux su: Unable to set user ID: Resource temporarily unavailable (Linux)
- Oracle 12c R2 new feature dbca command to create a standby database (Database)
- ElasticSearch basic usage and cluster structures (Server)
- Install mono offline on CentOS (Server)
- On the design of Oracle database backup (Database)
- Git Experience Sharing - Using a remote repository (Linux)
- Talk about Java in the collection (Programming)
- Ubuntu 14.04 / Linux Mint 17 How to install the MintMenu 5.5.2 menu (Linux)
- Hadoop 2.7.1 Installation and Configuration under RedHat Linux 6.5 (Server)
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.