Submit code to github hosting

Liao Xuefeng official website: https://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000, a great place for beginners

1. Create SSH Key

Since the transmission between the local Git repository and the GitHub repository is encrypted by SSH, you need to create an SSH Key. The command is as follows:

$ ssh-keygen -t rsa -C "[email protected]"

一路回车,使用默认值即可

2. Test whether to connect to the github server

Command line: ssh -T [email protected]

 

3. Upload the project code folder to your repository on github ( also the error: src refspec master does not match any solution when uploading from github )

  • Turn the project directory into a repository that Git can manage

    git init

  • Add all the contents of the project folder to the staging area

    git add .

  • Commit the files in the staging area

      git commit -m 'Initial commit project'

  • Associate a local repository with a remote repository (you must first have a remote repository eg: create one on github; https://xxxxxxx.git is your remote repository path)

    git remote add origin https://xxxxxxx.git

  • Pushing the contents of the local library to the remote, with the git pushcommand, actually pushes the current branch masterto the remote. Since the remote library is empty, when you push the branch for the first timemaster , adding -uparameters, Git will not only masterpush the local branch content to the remote new masterbranch, but also associate the local masterbranch with the remote masterbranch.

    git push -u origin master (If the username and email address are not configured, then you need to execute the following commands: git config --global user.name "XXX" and git config --global user.email "[email protected]" )

4. After creating a Git repository locally, I want to create a Git repository on GitHub

Teacher Liao's introduction is more detailed: https://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000/0013752340242354807e192f02a44359908df8a5643103a000

5. Assuming we develop from scratch, the best way is to create a remote library first, and then clone from the remote library

https://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000/001375233990231ac8cf32ef1b24887a5209f83e01cb94b000

6. Change the remote URL

https://help.github.com/articles/changing-a-remote-s-url/

https://help.github.com/articles/which-remote-url-should-i-use/ (pros and cons of both paths)

In fact, when using https, the security is high, but it is very troublesome. Every time you git clone, git fetch, git pull, or git pushuse the command line remote repository in the HTTPS URL, you will be asked to enter your GitHub username and password .

The ssh url is not very secure, so you don't need to enter your GitHub username and password.

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325290217&siteId=291194637