github/ssh key setting/clone/combined software

ssh advantages

There are two ways to submit code to github, https url, ssh url, the
latter does not require frequent account password verification, which is more convenient, once configured for permanent use, provided that the local private key is saved

ssh generates settings key

step:

  1. First create the id_rsa file locally, that is, the ssh key, which is the public key and the private key respectively
  2. Add the public key to the ssh configuration of github
  3. ssh application
  4. some problems

View ssh key file

  • First check whether there is already an ssh file
    cd into the directory, ls check the files and folders in the current directory, ll displays more detailed
    Insert picture description here
    If there is already an id_rsa file, you should remember whether you have set a password for it before copying the public key to github
    If you forget the password, it will be unavailable when downloading and uploading files using ssh key. It is better to regenerate the overlay and reset the password.
    If you remember, check the public key and copy it to github
cat id_rsa.pub

Insert picture description here

Set the public key to github

After getting the secret key, copy it into github-"setting
Insert picture description here
new ssh key, then copy the public key to it, and give it a name.
Insert picture description here

Generate ssh key file

If the id_rsa file does not exist locally, just re-create it, and the post-operation processing is the same as above.
Create a user name and email

git config --global user.name "git用户名"
git config --global user.email  "“email地址”

Insert picture description here

Generate secret key

ssh-keygen -t rsa -C "email地址"

You will be prompted to save the location and password of the ssh key. Set it yourself.
Pay attention to the file path problem.
If it is the c drive idea folder, it should be written as /c/idea instead of c:/idea. The path is special. Look at the example. My default address is
Insert picture description here

Link to github and clone project

After obtaining the public key secret key, the operation is the same as above, you can view the file

  • Why can't the setup succeed?
    The command in the first line of the following figure will prompt Hi after success
  • How to download files using git ssh?
    Find the ssh address in the download bar of github, and use git clone XX, as shown in the figure below.
    Because ctrl c was interrupted when I downloaded it, I didn’t download it, just as a demonstration
    Insert picture description here

Common ssh key configuration problems

  • problem? Where is the ssh key stored locally?

When generating the secret key, it is recommended to jump to the username ./ssh directory, and the id_ras file will be automatically generated below
that is cd ~/.ssh

  • If I use git's ssh to download a file, where will the file be downloaded?
    If it is already downloaded, use ls to view the downloaded directory,
    then cd / jump
    and then pwd to print out the full path
  • How to customize git download path?
git init

Generated in the corresponding directory. The ssh file is downloaded to the corresponding address by default

  • How to submit a project that has been submitted using https to ssh?
    Jump to the item used
例如: cd /c/Users/Adminstrator/IdeaProjects/total_case`

View submission method

git remote -v

Reset the https submission method to ssh submission method, the ssh path can be obtained from your project on github, for example

 git remote set-url origin git@github.com:Jonekaka/for_web.git

Insert picture description here
Or directly modify the config file in the .git folder in the project directory, modify the address,
Insert picture description here
you can see the https submission method
Insert picture description here
, and revisit the configuration file after the modification,
Insert picture description here
you can see that the address has been modified

The content of the config file under the project path.git file
Insert picture description here

Cooperate with idea to download and upload projects

idea->file->setting

  • First see if you can recognize the git.exe file

Insert picture description here
Go to github in the same directory, select the password input format, enter the account name and password, or token. If you select token and click to generate it, you will understand at a glance. If you don’t want to say
and then test, sometimes you will not be able to ping. It doesn’t work. Network problems.
See the git ssh below? It’s the above. Finally, you don’t need to write the account password every time you upload and download, but note that new projects should pay attention to using the new git address. Uncheck it, idea has the function of recording account password
Insert picture description here

  • Add the project that needs to be uploaded to the virtual warehouse.
    Insert picture description here
    Select the project, and all the files inside will turn red, indicating that you have selected the
    right-click project and put the file in the temporary storage area. At this time, it has not been uploaded to github, and the file becomes green.
    Insert picture description here
    Submit The project turns white, you will be prompted to create a warehouse for the project, add a description, and then you can find it in github
    Insert picture description here
  • Is the project updated?
    The file turns green in minutes to remind you that you haven't uploaded it yet. The above steps will only update the new file.
    Why is it green? The warehouse has been built and has been placed in the staging area by default
    or it can be submitted like this
    Insert picture description here

Want to delete the project?

Insert picture description here
Click and drag to the end, enter the project path name to confirm
Insert picture description here

Guess you like

Origin blog.csdn.net/lidashent/article/details/107948698