The software construction course has just finished the biggest boss of the experimental course, and has entered Lab4. I have experienced some advantages and conveniences of uploading to the GitHub repository. Because each experiment needs to associate the locally created repository with the remote repository created by the course, record the association method here.
1. Configure SSH Key
If you have not performed related operations with a git account before, you need to configure the SSH Key and set the secret key before the first association.
You can search to see if it has been configured:
in the main directory (this is not the local address of your git, search for .ssh in the Windows search bar), and see if there is a .ssh directory. If so, check if there is any in this directory. If the two files id_rsa and id_rsa.pub exist, it means that they have been configured and you can go to the next step directly
Configuration process:
Open Git Bash on Windows, create an SSH Key first, and enter the password as prompted. You can leave the password blank and press Enter all the way.
$ ssh-keygen -t rsa -C mailbox
Replace the mailbox with your own git mailbox
Then you will find a .ssh file, which contains id_rsa and id_rsa.pub, the former is the private key and the latter is the public key
Open the id_rsa.pub file and copy the contents
Log in to GitHub, enter Settings, open SSH and GPG Keys, select Add SSH key at the top of SSH keys, fill in any Title at Title, and paste the content you just copied at Key
Test whether the SSH Key is successfully configured: use the command
ssh -T [email protected]
If you've successfully authenticated, but GitHub does not provide shell access appears. This means that you have successfully connected to GitHub
Second, the local warehouse is associated with the remote warehouse
git init //initialization of the local warehouse, a hidden directory of .git will be generated
git add . //add all files
git commit -m "comment"
git remote add origin [email protected]:.....git.git //Replace with SSH of your own warehouse
git push -u origin master //
The -u parameter is added for the first use, which is to push the content and associate the branch
Note: The local warehouse cannot be empty when associated
Implement the link between the local warehouse and the remote warehouse on GitHub