When I first used Git to upload my domo to GitHub for a long time, I encountered many pits and consulted a lot of information, and finally uploaded successfully. Summarize some of your problems so you don’t forget.
1. Download Git software:git-scm.com/downloadsYou can follow the online tutorial step by step
2. You can directly mouse click on Git Bash screen, then CD to your project address
- Note: If you use Git for the first time, you may get an error if you copy the address directly and paste it on CD. Because there is a \ escape problem, you can slowly CD layer by layer into first
- Recommended method: Open the project folder you want to upload, right-click Git Bash in the current folder, Git will directly go to the current folder, do not need to CD again to enter
3. Enter git init
- Local git management is generated in the current project directory.
4. Enter git add.
- Note: there is a space before the “.”
- Add all the files on the project to the repository. You can also add a specific file. Replace the “.” with a specific file name
5. Configure the email address and name on Git for the first time
- Please tell me who you are.
- Configure the email: It doesn’t have to be on GitHub
git config --global user.name "user.name"Git config --global user.email git config --global user.email"[email protected]"// Enter a valid mailboxCopy the code
6. Generate a key
- Type: ssh-keygen -t rsa -c “[email protected]” (fill in the quotation marks with the email address you set above) and press Enter
- Success is indicated if a similar character encoding exists
- The user address on drive C of your computer will generate a hidden.ssh folder
- Open the id_rsa.pub file inside notepad and copy all the contents inside. Use it later
7. Create an SSH key on GitHub
You cannot upload a project without adding a key
- Enter the Setting
- Click SSH and GPG Keys, and then click Add New SSH Key
- Copy the contents of idb_rsa.pub to the Key and fill in the Title
- Enter SSH -t [email protected] in Git
- You’ve successfully authenticated, but GitHub does not provide shell access. This means you have successfully connected to Github.
8. Create a repository on GitHub
- To create a repository, click New Repository on GitHub
- Once created, copy the project address for later uploading
9. Associate the GitHub repository with the local repository
- Git remote add Origin http://…. (Your warehouse address)
10. Push all your local content to the GitHub repository
- Git push -u origin master
- Since the new remote repository is empty, the -u parameter should be added, which can be omitted when the repository has content
- If a similar interface is displayed after a period of time, the system succeeds