Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install and use git under Linux

2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly shows you how to install and use git under Linux. The content is easy to understand and clear. I hope it can help you solve your doubts. Let me take you to study and learn how to install and use git under Linux.

What is Linux system Linux is a free-to-use and free-spread UNIX-like operating system, is a POSIX-based multi-user, multi-task, multi-threaded and multi-CPU operating system, using Linux can run major Unix tools, applications and network protocols.

Installation and use of Git under Linux

Installation steps

First of all, you need to make sure that there is no git in the Linux. You can use the git command in the middle of the computer to check it, if you do not install it with the command sudo apt-get install git command.

To configure git after installation, you need to make sure that your open source Chinese account is connected, and you need to command git config-global user.name "XXX" and git config-global user.eamil "email address".

After the configuration is completed, you need to create an authenticated public key (same as under windows), and each user needs an independent public key to determine it. 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 the id_rsa.pub file. The contents of the file is the ssh public key, copy it all. Open the open source Chinese URL, choose to add the ssh public key, enter the content of the title at will, and paste the copied content into it.

You can use the command ssh-T git@git.oschina.net to test for success.

Need to pay attention to in installation

Note that the command ssh-keygen-C 'you email address@gmail.com'-t rsa is used during configuration (note that there is no space between ssh and-keygen)

After entering this command, there will be Enter file in which to save the key (/ home/haohao/.ssh/id_rsa) as an input option, never mind whether to create a file at the default address or in a newly entered place (new file name), just enter, and you can create a new ssh file at the default address.

Be sure to use gedit id_rsa.pub to open id_rsa.pub files or errors may occur.

When entering the file ~ / .ssh folder, just use the command to enter. If you look for it from my computer with the mouse, you may not be able to find it, because this folder .ssh is a hidden folder by default. So you don't have to worry about the computer if you can't find it, it's just hidden.

Git usage

After that, the operation is the same as the operation under Windows, first create a folder, copy the typed code into it, initialize a git repository with the git init instruction, and then type git add. (note: add and. Add a file and enter a git commit-m "comment" to submit to the warehouse.

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

Push can be completed by git push origin master.

Another way to push code is based on teamwork on the same project. I don't know if the process is legal, but the result is the same, and it works all the time.

First, git 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 the folder does not need a file format name, there is a file name), git status, git commit-m "comments", git push origin master input account number and information to complete the push. It will be very fast, and the command is simpler than the first one, easy to remember and improve efficiency.

experience

There was actually some contact last semester about the use of git, a program that can quickly improve the work of programmers. This semester in the Linux environment also came into contact with Git, but has been due to their own laziness without hands-on practice, always feel that there will be git under windows, then git will certainly be under Linux environment. But it is still not mastered, and there are still unexpected problems. For example, although the git under this Linux has been contacted before, there are still some problems in its own configuration, and there are still some problems that need to be consulted by classmates.

And it can also make mistakes when entering simple commands, such as returning to the upper folder cd.. When I typed, I didn't enter a space, and then I reported an error without the command, and I didn't know where I was wrong. Including cd ~ go back to the previous directory, cd-return to a certain directory all need spaces.

Although it has been found that new ways to use git can speed up efficiency, the basic knowledge is not solid and everything is still zero. The study of computer control system knowledge still needs to work hard and study hard. This knowledge must be operated on the computer. If you don't operate, you will never know if you have mastered it or not.

The above is about "how to install and use git under Linux". If changing the article is helpful to you and think it is good, please share it with your friends to learn new knowledge. if you want to know more about it, please pay more attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 224

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report