简体   繁体   中英

error: failed to push some refs to 'https://github.com/loliadus/djangolocallibrary.git'

So I'm trying to update the addition of new folders and files to a git repository. After cloning the repository and copying those folders and files to the repository, I run the following commands

C:\Users\Ben\Documents\djangoprojects\djangolocallibrary>git add -A

C:\Users\Ben\Documents\djangoprojects\djangolocallibrary>git status
On branch main
Your branch is up to date with 'origin/main'.

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        modified:   .gitignore
        new file:   catalog/__init__.py
        new file:   catalog/admin.py
        new file:   catalog/apps.py
        new file:   catalog/forms.py
        new file:   catalog/migrations/0001_initial.py
        new file:   catalog/migrations/0002_bookinstance_borrower.py
        new file:   catalog/migrations/0003_auto_20201007_2109.py
        new file:   catalog/migrations/__init__.py
        new file:   catalog/models.py
        new file:   catalog/static/css/styles.css
        new file:   catalog/templates/base_generic.html
        new file:   catalog/templates/catalog/author_confirm_delete.html
        new file:   catalog/templates/catalog/author_detail.html
        new file:   catalog/templates/catalog/author_form.html
        new file:   catalog/templates/catalog/author_list.html
        new file:   catalog/templates/catalog/book_confirm_delete.html
        new file:   catalog/templates/catalog/book_detail.html
        new file:   catalog/templates/catalog/book_form.html
        new file:   catalog/templates/catalog/book_list.html
        new file:   catalog/templates/catalog/book_renew_librarian.html
        new file:   catalog/templates/catalog/bookinstance_list_borrowed_all.html
        new file:   catalog/templates/catalog/bookinstance_list_borrowed_user.html
        new file:   catalog/templates/index.html
        new file:   catalog/tests/__init__.py
        new file:   catalog/tests/test_forms.py
        new file:   catalog/tests/test_models.py
        new file:   catalog/tests/test_views.py
        new file:   catalog/urls.py
        new file:   catalog/views.py
        new file:   locallibrary/__init__.py
        new file:   locallibrary/asgi.py
        new file:   locallibrary/settings.py
        new file:   locallibrary/urls.py
        new file:   locallibrary/wsgi.py
        new file:   manage.py
        new file:   templates/logged_out.html
        new file:   templates/registration/login.html
        new file:   templates/registration/password_reset_complete.html
        new file:   templates/registration/password_reset_confirm.html
        new file:   templates/registration/password_reset_done.html
        new file:   templates/registration/password_reset_email.html
        new file:   templates/registration/password_reset_form.html


C:\Users\Ben\Documents\djangoprojects\djangolocallibrary>git commit -m "Version 1.0 moved into Github"
[main a706353] Version 1.0 moved into Github
 43 files changed, 1577 insertions(+)
 create mode 100644 catalog/__init__.py
 create mode 100644 catalog/admin.py
 create mode 100644 catalog/apps.py
 create mode 100644 catalog/forms.py
 create mode 100644 catalog/migrations/0001_initial.py
 create mode 100644 catalog/migrations/0002_bookinstance_borrower.py
 create mode 100644 catalog/migrations/0003_auto_20201007_2109.py
 create mode 100644 catalog/migrations/__init__.py
 create mode 100644 catalog/models.py
 create mode 100644 catalog/static/css/styles.css
 create mode 100644 catalog/templates/base_generic.html
 create mode 100644 catalog/templates/catalog/author_confirm_delete.html
 create mode 100644 catalog/templates/catalog/author_detail.html
 create mode 100644 catalog/templates/catalog/author_form.html
 create mode 100644 catalog/templates/catalog/author_list.html
 create mode 100644 catalog/templates/catalog/book_confirm_delete.html
 create mode 100644 catalog/templates/catalog/book_detail.html
 create mode 100644 catalog/templates/catalog/book_form.html
 create mode 100644 catalog/templates/catalog/book_list.html
 create mode 100644 catalog/templates/catalog/book_renew_librarian.html
 create mode 100644 catalog/templates/catalog/bookinstance_list_borrowed_all.html
 create mode 100644 catalog/templates/catalog/bookinstance_list_borrowed_user.html
 create mode 100644 catalog/templates/index.html
 create mode 100644 catalog/tests/__init__.py
 create mode 100644 catalog/tests/test_forms.py
 create mode 100644 catalog/tests/test_models.py
 create mode 100644 catalog/tests/test_views.py
 create mode 100644 catalog/urls.py
 create mode 100644 catalog/views.py
 create mode 100644 locallibrary/__init__.py
 create mode 100644 locallibrary/asgi.py
 create mode 100644 locallibrary/settings.py
 create mode 100644 locallibrary/urls.py
 create mode 100644 locallibrary/wsgi.py
 create mode 100644 manage.py
 create mode 100644 templates/logged_out.html
 create mode 100644 templates/registration/login.html
 create mode 100644 templates/registration/password_reset_complete.html
 create mode 100644 templates/registration/password_reset_confirm.html
 create mode 100644 templates/registration/password_reset_done.html
 create mode 100644 templates/registration/password_reset_email.html
 create mode 100644 templates/registration/password_reset_form.html

C:\Users\Ben\Documents\djangoprojects\djangolocallibrary>git push origin master

However, after running these lines of code, I get the following error

error: src refspec master does not match any
error: failed to push some refs to 'https://github.com/loliadus/djangolocallibrary.git'

I have this error for a while and I don't know how to fix it. Could someone please help me? Thank you!

Your status output shows that for whatever reason this repo calls its default branch main instead of master . So you don't have a master branch unless you create one; you are on the main branch and that's what you need to push.

So I think since October 1st, 2020, Github has started to naming it's default branch as "main" as opposed to "master" like it used to. Original Github Documentation

To continue with using the convention of using master branch, you can create a master branch and push your changes to the same by using the following command

git push origin HEAD:master

If you are repository owner, you can also head to github to set master as your default branch. Simply log into your GitHub account, head to your repo and on the far right side in the navigation menu choose Settings . Then head to Branches and choose Default Branch

However, if you wish to adopt the new convention, use the following command

git push origin main

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM