Home Development Tools git Installation and use of git under Linux

Installation and use of git under Linux

Mar 02, 2021 am 09:29 AM
git linux

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!

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to delete a repository by git How to delete a repository by git Apr 17, 2025 pm 04:03 PM

To delete a Git repository, follow these steps: Confirm the repository you want to delete. Local deletion of repository: Use the rm -rf command to delete its folder. Remotely delete a warehouse: Navigate to the warehouse settings, find the "Delete Warehouse" option, and confirm the operation.

What to do if the git download is not active What to do if the git download is not active Apr 17, 2025 pm 04:54 PM

Resolve: When Git download speed is slow, you can take the following steps: Check the network connection and try to switch the connection method. Optimize Git configuration: Increase the POST buffer size (git config --global http.postBuffer 524288000), and reduce the low-speed limit (git config --global http.lowSpeedLimit 1000). Use a Git proxy (such as git-proxy or git-lfs-proxy). Try using a different Git client (such as Sourcetree or Github Desktop). Check for fire protection

How to download git projects to local How to download git projects to local Apr 17, 2025 pm 04:36 PM

To download projects locally via Git, follow these steps: Install Git. Navigate to the project directory. cloning the remote repository using the following command: git clone https://github.com/username/repository-name.git

How to solve the efficient search problem in PHP projects? Typesense helps you achieve it! How to solve the efficient search problem in PHP projects? Typesense helps you achieve it! Apr 17, 2025 pm 08:15 PM

When developing an e-commerce website, I encountered a difficult problem: How to achieve efficient search functions in large amounts of product data? Traditional database searches are inefficient and have poor user experience. After some research, I discovered the search engine Typesense and solved this problem through its official PHP client typesense/typesense-php, which greatly improved the search performance.

How to update code in git How to update code in git Apr 17, 2025 pm 04:45 PM

Steps to update git code: Check out code: git clone https://github.com/username/repo.git Get the latest changes: git fetch merge changes: git merge origin/master push changes (optional): git push origin master

How to submit empty folders in git How to submit empty folders in git Apr 17, 2025 pm 04:09 PM

To submit an empty folder in Git, just follow the following steps: 1. Create an empty folder; 2. Add the folder to the staging area; 3. Submit changes and enter a commit message; 4. (Optional) Push the changes to the remote repository. Note: The name of an empty folder cannot start with . If the folder already exists, you need to use git add --force to add.

How to connect to the public network of git server How to connect to the public network of git server Apr 17, 2025 pm 02:27 PM

Connecting a Git server to the public network includes five steps: 1. Set up the public IP address; 2. Open the firewall port (22, 9418, 80/443); 3. Configure SSH access (generate key pairs, create users); 4. Configure HTTP/HTTPS access (install servers, configure permissions); 5. Test the connection (using SSH client or Git commands).

How to add public keys to git account How to add public keys to git account Apr 17, 2025 pm 02:42 PM

How to add a public key to a Git account? Step: Generate an SSH key pair. Copy the public key. Add a public key in GitLab or GitHub. Test the SSH connection.

See all articles