Home > Development Tools > git > body text

Installation and use of git under Linux

coldplay.xixi
Release: 2021-03-02 09:29:23
forward
3679 people have browsed it

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 the git command in the computer to check. If not, use the command sudo apt-get install git to 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 commands git config --global user.name "XXX" and git 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 command ssh-key -C 'your email address' -t rsa, and the corresponding key file will be created in the user directory ~/.ssh/

  • Then use the command cd ~/.ssh to enter the folder and use gedit id_rsa.pub to open id_rsa. pub file. 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 command ssh -T git@git.oschina.net to test whether it is successful.

Need to pay attention during installation

  • Be careful to use the command when configuring ssh-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 of Enter 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 new ssh file at the default address.

  • ##Be sure to use

    when opening the id_rsa.pub file gedit id_rsa.pubOtherwise an error may occur.

  • When entering the file

    ~/.ssh folder, 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 .ssh is 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 init command to initialize a git warehouse, and then enter git add . (note: add and . There are spaces between ) to add the file, enter git 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 master to 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 commands git 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 folder cd ..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. Including cd ~ 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!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!