繁体   English   中英

错误:无法将一些引用推送到“https://github.com/loliadus/djangolocallibrary.git”

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

所以我正在尝试将新文件夹和文件的添加更新到 git 存储库。 克隆存储库并将这些文件夹和文件复制到存储库后,我运行以下命令

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

但是,运行这些代码行后,出现以下错误

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

我有一段时间有这个错误,我不知道如何解决。 有人可以帮我吗? 谢谢!

您的状态 output 表明无论出于何种原因,此回购调用其默认分支main而不是master 因此,除非您创建一个master分支,否则您没有主分支; 你在main分支上,这就是你需要推动的。

所以我认为自 2020 年 10 月 1 日起,Github 已开始将其默认分支命名为“main”,而不是像以前那样命名为“master”。 原始 Github 文档

要继续使用 master 分支的约定,您可以创建一个 master 分支并使用以下命令将您的更改推送到该分支

git push origin HEAD:master

如果您是仓库所有者,您也可以前往 github 将 master 设置为您的默认分支。 只需登录您的 GitHub 帐户,前往您的存储库,然后在导航菜单的最右侧选择Settings 然后前往Branches并选择Default Branch

但是,如果您希望采用新约定,请使用以下命令

git push origin main

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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