error: cannot run .git/hooks/pre-commit: No such file or directory解決方法

在執行git命令的時候,可以正常執行git status 命令
但是commit 失敗,報error: cannot run .git/hooks/pre-commit: No such file or directory
查看倉庫 .git/hooks/pre-commit文件也存在,折騰了很久
發現執行如下命令後就OK了

cp .git/hooks/pre-commit /tmp/pre-commit
tr -d ‘\r’ < /tmp/pre-commit > .git/hooks/pre-commit

執行如上命令後,又報瞭如下兩個錯誤:
error: cannot run .git/hooks/prepare-commit-msg: No such file or directory
error: cannot run .git/hooks/commit-msg: No such file or directory

同理,繼續執行命令:
cp .git/hooks/prepare-commit-msg /tmp/
tr -d ‘\r’ < /tmp/prepare-commit-msg > .git/hooks/prepare-commit-msg

cp .git/hooks/commit-msg /tmp/
tr -d ‘\r’ < /tmp/commit-msg > .git/hooks/commit-msg

完美解決

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章