所以我正在尝试将新文件夹和文件的添加更新到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'
我有一段时间这个错误,而且我不知道如何解决。有人可以帮我吗?谢谢!
答案 0 :(得分:0)
您的状态输出显示,无论出于何种原因,此回购都调用其默认分支main
而不是master
。因此,除非创建一个分支,否则没有master
分支;您位于main
分支上,这就是您需要推送的内容。
答案 1 :(得分:0)
因此,我认为自2020年10月1日起,Github已开始将其默认分支命名为“ main”,而不是以前的“ master”。 Original Github Documentation
要继续使用使用master分支的惯例,您可以创建一个master分支,并使用以下命令将更改推送到同一分支
git push origin HEAD:master
如果您是存储库所有者,则还可以转到github将master设置为默认分支。只需登录您的GitHub帐户,转到您的仓库,然后在导航菜单的最右侧选择设置。然后转到分支,然后选择默认分支
但是,如果您希望采用新的约定,请使用以下命令
git push origin main