Local git repository and remote repository creation and correlation and GitHub upload (git push) error:src Refspec master does not match any solution

Source: Internet
Author: User

GitHub Upload Project Method:

Install Git on your computer

Git Bash Here

The general process for creating and correlating local git repositories and remote repositories is:

1. Initialize this local folder as a Git manageable repository

Git init

Note: Git will automatically create a unique branch for US master
We can find a directory in the current directory .git , this directory is git to track the management of the repository, do not manually modify the files in this directory, or change the mess, the Git repository to destroy.

2. Associate a local warehouse with a remote warehouse

git remote add origin [email protected]:littleredhatli/webpratice.git

[Email Protected]:littleredhatli/webpratice.git is the path to our remote repository (Webpratice is the name of the remote repository)

3. Create a new file

Touch Index

4. Add the new main.m file to the repository (so git will have 追踪 this file)

Git add index

5. Submit the file to the warehouse

" Commentary on the document "

6. Push the contents of the local library to the remote

Git push-u Origin Master

Note: For the first time push , with -u parameters, Git will associate the local master branch with the remote Master branch, and we will push no longer need to add parameters to our operations -u .

If one day we have modified the mian.m file

Modify the index file
    • We can use
      git status

      View status

    • Adding files to the Git repository is actually 文件修改 adding to the暂存区
Git add index
Git commit-m "Commentary on a file"

git push
    • Commit changes to push the latest changes to the local current branch to the remote repository on GitHub

github上传(git push)时出现error: src refspec master does not match any

The cause of this error is that there are no files in the directory and an empty directory cannot be submitted.

Solutions

Touch Readme
git add README
git commit-m "Commentary"
Git push Origin Master

If you already have a file on GitHub remote, an error will occur. At this point, you should pull the first, namely:

Git pull Origin Master

And then proceed:

Git push Origin Master

Local git repository and remote repository creation and correlation and GitHub upload (git push) error:src Refspec master does not match any solution

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.