Home>Article>Development Tools> Installation and use of git under Linux

Installation and use of git under Linux

coldplay.xixi
coldplay.xixi forward
2021-03-02 09:29:23 3623browse

Installation and use of git under Linux

Git installation and use under Linux

Installation steps

  • First, you need to confirm whether there is git in Linux. You can use thegitcommand in the computer to check. If not, use the commandsudo apt-get install gitto install it.

Recommended (free):Git tutorial

  • Configure git after the installation is complete , you need to ensure that the connection is your open source China account, you need the commandsgit config --global user.name "XXX"andgit config --global user.eamil "email address"

  • After the configuration is completed, you need to create a public key for verification (the same as under windows). Each user needs an independent public key. to make sure. Use the commandssh-key -C 'your email address' -t rsa, and the corresponding key filewill be created in the user directory~/.ssh/

  • Then use the commandcd ~/.sshto enter the folder and usegedit id_rsa.pubto openid_rsa. pubfile. The content in the file is the ssh public key, copy it all. Open the open source China website, choose to add the ssh public key, enter the content of the title as you like, and then paste the copied content into it and you are done.

  • You can use the commandssh -T git@git.oschina.netto test whether it is successful.

Need to pay attention during installation

  • Be careful to use the command when configuringssh-keygen -C 'you email address@gmail.com' -t rsa(note that there is no space between ssh and -keygen)

  • After entering this command There will be an input option ofEnter file in which to save the key (/home/haohao/.ssh/id_rsa). Don’t worry about it. This is to choose whether to create the file at the default address or in a new input place. Create (new file name), press Enter, and you can create a newssh fileat the default address.

  • ##Be sure to use

    when opening theid_rsa.pubfile gedit id_rsa.pubOtherwise an error may occur.

  • When entering the file

    ~/.sshfolder, just use the command to enter. If you use the mouse to search for it from my computer, you may not be able to find it. Because this folder.sshis a hidden folder by default. So if you can't find it, you don't have to worry that it's a computer problem, it's just hidden.

The operation after using Git

  • is the same as the operation under Windows. First create a folder yourself , copy the typed code into it, first use the

    git initcommand to initialize a git warehouse, and then entergit add .(note:addand. There are spaces between) to add the file, entergit commit -m "comment" to submit to the warehouse.

  • Enter

    git remote add origin https://git.oschina.net/your username/project name.git, enter your account and password.

  • git push origin masterto complete the push.

  • Another way to push code was discovered when working together as a team to complete the same project. I don’t know if the process is legal or not, but the result is the same and it works repeatedly.

  • Firstgit clone project address: The project will be downloaded and stored in the folder you created.

  • Then copy the folder of the code that needs to be submitted to the downloaded folder. Use the commandsgit status,git add XXX.File format name(if it is a folder, you do not need a file format name, just have a file name),git status,git commit -m"comment",git push origin masterEnter the account number and information to complete the push. It will be faster, and the command is simpler than the first one, making it easier to remember and improve efficiency.

Experience

I actually came into contact with the use of git last semester. This is a tool that can quickly improve the work of programmers. program. I also came into contact with Git in the Linux environment this semester, but I have never practiced it due to my laziness. I always felt that if I know git under windows, I will definitely know git under the Linux environment. But I still haven’t mastered it, and there are still unexpected problems. For example, although I have been exposed to git under Linux before, I still have problems when configuring it myself, and I still need to ask my classmates for advice.

And when you simply enter a command, you will make a mistake, such as returning to the upper foldercd ..I did not enter a space when typing, and then an error was reported that there was no such command, and there was no such command. Don't know where I went wrong. Includingcd ~to return to the previous directory,cd -to return to a certain directory, all require spaces.

Although I have discovered a new way to use git that can speed up efficiency, if I don’t have a solid grasp of basic knowledge, everything is still 0. Learning computer operating system knowledge still requires hard work and study. This aspect of knowledge must be practiced on the computer. If you don’t operate it, you will never know whether you have mastered it.

The above is the detailed content of Installation and use of git under Linux. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete