본문 바로가기
🚧에러모음

[Git] error: pathspec 'message' did not match any file(s) known to git

by 서버요정 호토론 2022. 9. 21.

[개발환경]

✔ Windows 10
✔ IntelliJ IDEA Ultimate 2022.1.3
✔ jdk 17.0.3.1

 

[문제상황]

작업내역을 저장하려고 하는데 add까진 되지만 commit이 안되는 상황 발생

 

$ git commit -m -s "Create deploy-docker-image.yml"
error: pathspec 'Create deploy-docker-image.yml' did not match any file(s) known to git

요런 에러메세지가 나오면서 커밋이 안된다ㅠㅠ

 

 

구글링을 해보며 다음과 같은 시도를 해보았다

 

1. git init

$ git init 
$ git add .
$ git commit -m "message"
$ git push origin master

 

2. git fetch

$ git remote update
$ git fetch
# git checkout 브랜치

 

3. git checkout -t

$ git checkout -t remote_name/branch_name

 

4. 레포지토리 삭제 후 다시 clone해서 커밋해보기

$ rm -rf 폴더명
$ git clone 저장소주소
$ git add .
$ git commit -m ""

 

5. 커밋메세지 큰따옴표로 쓰기 (나는 해당없음)

 

결과는 실패.....

 

 

 

[원인]

긴긴 삽질 후 발견한 원인은?

git commit할때 -m 옵션 바로옆에 커밋메세지를 써야해서 그랬던거였다.........

옵션 쓸때는 사용법을 잘 익혀야겠다..ㅎㅎ

 

[해결방법]

git commit -m -s "커밋메세지" (X)

git commit -m "커밋메세지" -s (O)

 

$ git commit -m "커밋메세지" -s

요렇게 -s옵션을 뒤로 배치했더니

 

요로코롬 깔꼼하게 해결⭐

옵션의 순서가 중요한지 몰랐다!!! 오늘 또 배웠다!!!

 

 

[참고문서]

https://opendive.tistory.com/646

 

[git] checkout 새로 추가된 브랜치 >> error: pathspec 'BRANCH-NAME' did not match any file(s) known to git.

repository 에 새로운 브렌치가 업데이트 되어서 checkout 해보려는 데 저런 에러가 뜬다 error: pathspec 'BRANCH-NAME' did not match any file(s) known to git. 브랜치가 업데이트 안되서 그런거니 이렇게 해..

opendive.tistory.com

https://rrecoder.tistory.com/88

 

git push 오류 error: pathspec '' did not match any file(s) known to git

Git 에서는 정말 각양각색의 사고가 일어난다. 오늘은 또 무슨일일까? <현재 상황 > 처음 push 하는상황 local의 step1 에서 이것저것 열심히 구현, 아래 그림처럼 commit 해놓고 하고 push 하려는 상황 git

rrecoder.tistory.com

https://fomaios.tistory.com/entry/%ED%95%B4%EA%B2%B0%EB%B2%95-error-pathspec-did-not-match-any-files-known-to-git

댓글