$ git show-ref
$ git push origin HEAD:main
error: src refspec HEAD does not match any.
error: failed to push some refs to 'https://github.com/ShridharMP/SpringBoot.git'
将新项目提交到 git hub 时出现错误:src refspec main does not match any
•
问答
zyuncx250 回答:将新项目提交到 git hub 时出现错误:src refspec main does not match any
嘿,您的问题似乎已经存在了。
请试试这个。如果您确定您的项目已链接到 git 存储库。
git add .
运行它以查看您的代码是否已添加/暂存
git status
然后使用下面的命令提交您的代码
git commit -m "put your message here"
然后确保使用此命令将代码推送到您希望它所在的分支
git push origin <branch here>
您也可以在此处查看此问题。 Message 'src refspec master does not match any' when pushing commits in Git
,添加未跟踪的文件后,我解决了这个问题
Shridhar Patil@ShridharMP MINGW64 /d/SpringBoot/DerivedMethodApplication (main)
$ **
> git status
**
On branch main
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: .gitignore
new file: .mvn/wrapper/MavenWrapperDownloader.java
new file: .mvn/wrapper/maven-wrapper.jar
new file: .mvn/wrapper/maven-wrapper.properties
Untracked files:
(use "git add <file>..." to include in what will be committed)
**mvnw
mvnw.cmd
pom.xml
src/**
Shridhar Patil@ShridharMP MINGW64 /d/SpringBoot/DerivedMethodApplication (main)
$
> git add mvnw
warning: LF will be replaced by CRLF in mvnw.
The file will have its original line endings in your working directory
Shridhar Patil@ShridharMP MINGW64 /d/SpringBoot/DerivedMethodApplication (main)
$ **
> git add mvnw.cmd
**
warning: LF will be replaced by CRLF in mvnw.cmd.
The file will have its original line endings in your working directory
Shridhar Patil@ShridharMP MINGW64 /d/SpringBoot/DerivedMethodApplication (main)
$ **
> git add pom.xml
**
warning: LF will be replaced by CRLF in pom.xml.
The file will have its original line endings in your working directory
Shridhar Patil@ShridharMP MINGW64 /d/SpringBoot/DerivedMethodApplication (main)
$ **
> git add src/
**
warning: LF will be replaced by CRLF in src/main/java/com/example/person/DerivedMethodApplication.java.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in src/main/resources/application.properties.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in src/test/java/com/example/ticketbookingapplication/DerivedMethodApplicationTests.java.
The file will have its original line endings in your working directory
$ **
> git commit -m "first commit"
**
[main (root-commit) 6562ff5] first commit
14 files changed,1156 insertions(+)
create mode 100644 .gitignore
create mode 100644 .mvn/wrapper/MavenWrapperDownloader.java
create mode 100644 .mvn/wrapper/maven-wrapper.jar
create mode 100644 .mvn/wrapper/maven-wrapper.properties
create mode 100644 mvnw
create mode 100644 mvnw.cmd
create mode 100644 pom.xml
create mode 100644 src/main/java/com/example/person/DerivedMethodApplication.java
create mode 100644 src/main/java/com/example/person/dao/PersonDAO.java
create mode 100644 src/main/java/com/example/person/model/Person.java
create mode 100644 src/main/java/com/example/person/model/PersonDTO.java
create mode 100644 src/main/java/com/example/person/service/PersonService.java
create mode 100644 src/main/resources/application.properties
create mode 100644 src/test/java/com/example/ticketbookingapplication/DerivedMethodApplicationTests.java
Shridhar Patil@ShridharMP MINGW64 /d/SpringBoot/DerivedMethodApplication (main)
$ **
> git push -u origin main
**
Enumerating objects: 33,done.
Counting objects: 100% (33/33),done.
Delta compression using up to 4 threads
Compressing objects: 100% (24/24),done.
Writing objects: 100% (33/33),55.51 KiB | 507.00 KiB/s,done.
Total 33 (delta 2),reused 0 (delta 0)
remote: Resolving deltas: 100% (2/2),done.