Home>Article>Development Tools> 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 thegit
command in the computer to check. If not, use the commandsudo apt-get install git
to install it.
Recommended (free):Git tutorial
git 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 ~/.ssh
to enter the folder and usegedit id_rsa.pub
to openid_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 commandssh -T git@git.oschina.net
to 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 file
at the default address.
when opening theid_rsa.pub
file gedit id_rsa.pubOtherwise an error may occur.
~/.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
git initcommand to initialize a git warehouse, and then enter
git add .(note:
addand
. There are spaces between) to add the file, enter
git commit -m "comment" to submit to the warehouse.
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.
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 master
Enter 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!