The premise is that we have created a version library (project folder) locally
Step 1: In the project folder directory, type git init on the command line to initialize the folder as a Git manageable library.
Git init is used to track and manage git versions. It is hidden by default.
Step 2: Execute “git add.” to add the file to the cache
Step 3: Connect to the remote database (gitHub)
Query the Github address of a project that has been created on Github
Command line execution:
Git remote add origin Git addressCopy the code
Step 4: After the association, push the local library to the remote repository
git push -u origin masterCopy the code
Since the new remote repository is empty, the -u parameter is added. Then go to GitHub and refresh the repository to see the uploaded folder.
- If the remote repository is not empty, an error is reported as follows:
This is because the README file in the newly created repository is not in the local repository directory. In this case, we can first merge the contents with the following command:
git pull --rebase origin masterCopy the code
Input again
git push origin masterCopy the code
This completes the process of uploading your local project to Github.
- An error
error: src refspec master does not match any.
error: failed to push some refs to 'git address'Copy the code
Direct execution
git commit -am “init”
And then execute
git push -u origin master
It worked.