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 generate SSH key in Git

2025-04-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces the relevant knowledge of "how to generate SSH key in Git". The editor shows you the operation process through an actual case. The operation method is simple, fast and practical. I hope this article "how to generate SSH key in Git" can help you solve the problem.

SSH key generation steps in Git

Because the transfer between the local Git repository and the GitHub repository is encrypted through SSH, it is necessary to have the github repository certify your SSH key, and before that, you must generate SSH key.

Step 1: create SSH Key. Check [C disk-> customer-> own customer name-> .ssh] under windows to see if there are id_rsa and id_rsa.pub files. If not, generate them manually.

Open git bash and enter the following command in the console.

$ssh-keygen-t rsa-C ``"youremail@example.com" `

The key type can be specified with the-t option. If not specified, the RSA key for SSH-2 is generated by default. Rsa is used here.

At the same time, there is a comment field in the key, which uses-C to specify the specified comment, which makes it convenient for the customer to identify the key, indicate the purpose of the key or other useful information. So enter your email or the rest here.

After input, the program is also required to enter a password string (passphrase), empty to indicate that there is no password. Then you will be asked to enter 2 passwords (password), which means there is no password. Enter 3 times to complete the current step, which has been generated in the [c disk > customer > customer name > .ssh] directory.

Step 2: log in to github. Open setting- > SSH keys, click New SSH key in the upper right corner, put the generated public key id_rsa.pub into the key input box, and then set a title for the current key to distinguish each key.

four。 The code is submitted.

1. In the root directory of the local project where the project is located, right-click and click "Git Bash Here" in the menu to enter the git command line input interface.

two。 Enter: git init, enter, initialize git warehouse. A .git folder is generated under the directory.

3. Input: git add. (there is a point in the command) to mark all files in the current directory as new files that need to be stored. Enter: git status to view the current warehouse status, you can see the newly added file status "new file: test123.txt"

4. Enter: git commit-m "First commit~", and the contents in quotation marks are submitted log

5. Enter: git log to see the records entered into the database

6. The local code is pushed to the remote git repository.

Enter: git remote add origin https://git.qcloud.com/cbuttonst/test.git to increase the remote warehouse address. If add's url is accidentally typed wrong, you can use: git remote set-url origin https://xxx to reset to the new url.

7. Enter: git pull-- rebase origin master will remind you to enter the customer name (the customer name in Tencent worker Bee), and a password input box will pop up after you enter (the password is also filled in by yourself during the account registration process). In this step, pull the remote warehouse file to the local warehouse and upgrade the local warehouse. The following message appears.

8. At this point, you can push local files to the remote warehouse. Enter the command: git push-u origin master push the local code to the remote git repository

After push is successful, you can see the uploaded source file in worker Bee's project.

This is the end of the content about "how to generate SSH key in Git". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

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: 0

*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