Install git in Centos 6.7

Source: Internet
Author: User

Install git in Centos 6.7

Written in front: the blogger is a linux hacker. As soon as he got in touch, he was ready to install git on linux and encountered various small issues.
1. From # to $, create your own user
2. yum failure
3. Solve the Problem of VM Centos Internet access 3.1-3.5
4. Change the yum source of the optical disk to the yum source of the network (the yum source of the network is used by default in linux. skip this step if you haven't tried it before)
5. Install git
6. if the version of yum to install git is too low, consider installing the source code package 6.1-6.7.
---- Not gorgeous split line -----------

1. Create your own users from # to $ (PS: it has nothing to do with git)

You can see that the installation of git in the tutorial is performed under $, so you also want to get a user account. In linux, there are 4 files related to the user:

  • /Etc/group stores information about all user groups in the current system
  • /Etc/gshadow user group password information
  • /Etc/passwd user information (passwd doesn't mean a password? Strange)
  • /Etc/shadow user password information
    Command Line for creating an account:
    Useradd-d/home/bigqiang
    Create a user named bigqiang.-d indicates that/home/bigqiang is the home directory. Use the su command to switch users from # to $, you can open/etc/passwd and check that the system has added a new user to the user.

2. Install yum and start to install git directly. command line:
Yum-y install git
Error:

The reason is that Centos has been installed and upgraded to python2.7, while the yum module is written in python. The new python2.7 does not have the default yum installation. All of them cannot be identified. solution, enter the yum file of the system:

vim /usr/bin/yum

Add Centos6.7 to the end of the first line. The default python version 2.6 is saved and exited, so that yum points to the default version. The problem is solved. 3. Enable the Virtual Machine Centos to access the Internet. Next, repeat the git installation command and find that git installation fails. Three files cannot be downloaded. When I learned yum, the yum source is equipped with a cost-effective yum source laboratory environment, because Centos was not connected to the Internet at that time, and local yum sources were useful when the server was initially built, the Local CD yum source may be missing three files required for installation (which file is irrelevant), so I decided to change the yum source back to the network yum source, connect to the yum server to become the real yum source. However, you must first enable Centos to access the Internet and build a network yum source. 5 steps to enable Centos to access the Internet: (step 1 and Step 2 have been completed earlier, and the specific steps are almost forgotten. Do not expand) 3.1. there are several ways to assign an ip address to linux: Use the ifconfig command to set a temporary IP address (it becomes invalid after restart, so it is not needed ); use the setup tool (for the Red Hat series ). 3. 2. Start the NIC command linevim /etc/sysconfig/network-scipts/ifcfg-eth0 Change ONBOOT = no to ONBOOT = yes to restart the network service:service network restart 3.3. generally, you do not need to modify the UUID because the VM has the ability to copy the system and the UUID of the copied system must be the same. Therefore, you need to modify the UUID, if you have a UUID installed on one instance, it will certainly not be repeated. 3.4. set virtual machine connection mode the virtual machine has three Connection Methods: bridging, using the real network card of your computer (physical network card), advantages: simple configuration, disadvantages: need to occupy a network segment IP; NAT, you can only communicate with your own real machine, but cannot connect to other IP hosts on the LAN. You can use the IP address of the real machine to access the Internet. HOST-only can only communicate with your own HOST and cannot access the Internet. You can select bridging. 3.5. modify the virtual network editor option in the edit option on the VMware interface, because the default option is an automatic network card (unreliable, I don't know what to choose automatically ), generally, computers have at least two NICs, wired and wireless. Select the corresponding NIC based on their network conditions. VMware1 and VMware8 correspond to NAT and HOST-only, ignore this. Now, the Centos networking settings are complete. Run the ping command to check whether the connection is successful. 4. now, you can change the yum source to the network yum source at/etc/yum. resos. d/has 4-5 yum source files by default. Currently, two functions are available. files with the base character are the yum source files that take effect by default. The network yum source is controlled. If not, you can rename the file, make it ineffective. The source file yum with Media is now in the file, and the enabled parameter is changed to 1 to 0, so that it becomes invalid. Save and exit. Then change the previously modified base file name back to the default value, so that the network yum takes effect. Since then, everything has been ready.

5. Complete all settings and install yum online:

yum -y install git

-Y indicates that the installation process automatically answers yes and then checks whether git can be used. git-version displays the git version, which is a result of great efforts. Just as I was celebrating...

6 It turns out that the lazy method requires a price. Because the git version installed by yum is too low 1.7.1, the following error occurs when I create a git remote database: one of the possible reasons is that the git version is too low. After reading the git update to 2.8.1 on the official website, I felt that my version was indeed a little low. I decided to install the new version for a try. It proved correct afterwards. On the yum server, the official version of git may be updated slowly, and the source code package is used directly. Preparation knowledge: first, the source code package is generally written in C language, so you must first follow the C language compiler gcc, available yum source installation, the blogger has been installed before, do not expand; second, the source code package is generally stored in/usr/local/src/, and the software installation location is usually in/usr/local/git (which software name creates the corresponding folder by yourself ), before installation, install the dependency package of the source code package with the yum source to solve the dependency relationship. Start installation: 6.1 download the source code package. Generally, the wget command is used. If you do not know where to download the package, the blogger can use the Windows environment to download the package first, use winscp software to directly copy to the source code package folder of the Centos environment. 6.2 decompress the source code package. Take xxx.tar.gz as an example. In the command line tar-zxcf xxx.tar.gz, tar was originally a packaged command and added-z, which makes it very convenient to compress the file with-z character tar.gz, there are other forms that do not expand. -X indicates the process of unpackaging-v display-f specifies the compressed file name. This command will decompress 6.3 in the current directory to enter the directory of the decompressed file. This is critical and must be done, otherwise, the subsequent steps are useless. 6.4 perform software configuration and check to see if there is any problem with the source code package. /configure-prefix =/usr/local/git can specify the installation location as the above directory, but this time the blogger did not do this. Use another command line: autoconf. /configure may automatically allocate the installation location. Because the earlier version of git is installed too low, you need to change the path. If you directly follow the command line of the tutorial, you will not specify the installation location. 6.5 run the command line: make to compile and translate it into machine language 6.6 for the final installation: make install. If no error is reported, the installation is successful. 6.7 modify the/etc/ld. so. conf file and add a line at the end:/usr/local/lib to save and close the file. (The blogger does not know what this step is, And autoconf is used only in step 1.) Here, you can check the git version, which is already a new version. No error is reported when you test the association with the git remote database to solve the problem.

When the commit version reaches the master branch, another error occurs: when solving the problem, you must remove-global from the command line to take effect. You can use the command line: git config-local-l to check whether the bug has been found for a long time, wasting a lot of time.

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.