GIT _ server and local environment build, git server build

Source: Internet
Author: User
Tags git client git commands

GIT _ server and local environment build, git server build

Install the git package in linux

The git version automatically installed on many yum sources is 1.7, Which is manually compiled and re-installed here.
1: Install the dependency package
Yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker
2: delete existing git
Yum remove git
3: Download the git source code and store the package files in the usr/src directory.
Cd/usr/src
Wget https://www.kernel.org/pub/software/scm/git/git-2.8.3.tar.gz
4: Decompress the git installation package
Tar-zxvf git-2.8.3.tar.gz
Cd git-2.8.3
5: configure the git installation path
./Configure prefix =/usr/local/git/
6. Compile and install
Make & make install
7. view the git version number.
Git -- version
8: Add git commands to bash
Vi/etc/profile
Add in the last line
Export PATH = $ PATH:/usr/local/git/bin
Effective configuration file
Source/etc/profile


Linux Remote repository Configuration
1: create a user and run the git Service
Adduser git
Passwd git
2: Create/data/git/repositories/test. git as our git Repository
Mkdir-p/data/git/repositories/test. git
Git init -- bare/data/git/repositories/test. git
Initialized empty Git repository in/data/git/repositories/test. git

Initialize git Repository
Git init -- bare test. git
Initialized empty Git repository in/data/git/repositories/test. git
3: Change the owner to git.
Cd data/git/
Chown git: git test. git

Local git environment Configuration
Install the git Client
Install git_bash
Https://pan.baidu.com/s/1oAmkSOUCommon git toolkit and materials (including 32-bit and 64-bit)
Create a local project address, such as d:/development/git/test. git.
Right-click git Bash Here under the test. Git directory
Create a local user
Git config -- global user. name ""
Create a local mailbox
Git config -- global user. email ""
Create a remote Branch
Git remote add origin git @Host:/Data/git/repositories/test. git
Local repository Initialization
Git init
Add all files to the local database index
Git add-

Submit all files in the working directory tree to the local library.
Git commit-a-m "init commit
Push the local database to the remote database above
Git push origin master

The origin is the remote database host name, and the master is the local branch name. If the remote branch does not exist, it will be created.
Enter the git user password to complete the push.
If the remote repository is not empty, run pull to retrieve updates from a branch of the remote host and merge the updates with the specified local branch.
Git pull origin master

 

Public key pair
Run the local bash command
Execute git clone git For The First Time @Host:/Data/git/repositories/test. git
The authenticity of host '10. ipv4.46 (10.20.4.46) 'can't be established.
If yes is selected, the known_hosts will be generated under C: \ Users \ git \. ssh, and will not be prompted when git is connected again later

Ssh-keygen
Press enter three times in a row to generate two files in C: \ Users \ git \. ssh.
Id_rsa and id_rsa.pub (Public Key)
Collect the public keys of all users who need to log on. The public keys are located in the id_rsa.pub file, and import our public keys to the/home/git /. one line in the ssh/authorized_keys file.
If the file does not exist, create it and modify the permissions of the corresponding file:
1. $ cd/home/git
2. $ mkdir. ssh
3. $ chmod 700. ssh
4. $ touch. ssh/authorized_keys
5. $ chmod 600. ssh/authorized_keys

Find C: \ Program Files \ TortoiseGit \ bin \ puttygen.exe in the TortoiseGit installation path)
Click load to load the private key id_rsa, and then click Save private key to generate the ppk file (id_rsa.ppk) required by TortoiseGit)


On the TortoiseGit Settings page, configure the relevant parameters as follows: configure the user name and mailbox, configure the server code path and the id_rsa.ppk Path obtained above, enter the Settings page of TortoiseGit, and click the Git directory in the left navigation bar, set the user Name and Email address (Name, Email). The Name will be displayed when the code is submitted. If you have configured it using git config before, you do not need to configure it here.
Then, click the Remote menu under Git to add a Remote repository point of origin: Remote is a Remote branch. Name. The URL is the remote repository address, and the Putty is the id_rsa.ppk file path.

Click "Network" and select "C: \ Program Files \ TortoiseGit \ bin \ TortoisePlink.exe" for the SSH client.

Now you can use TortoiseGit to work properly. You can try pull, commit, and other functions.

 

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.