Closed2

Git関係のコマンドに対するエラーの対処法まとめ

dev8dev8

対策1: コミットできない

以下のエラーメッセージが出た場合はこの対処法で多分大丈夫。

.git/hooks/commit-msg: line 1: Author:: command not found
.git/hooks/commit-msg: line 2: Committer:: command not found

ファイルの中身を確認

以下のコマンドを実行して.git/hooks/commit-msgファイルの中身を確認します。一時的にAuthorとCommitterの要素を削除します。これによりコミットできるようになります。

nano .git/hooks/commit-msg
dev8dev8

対策2: プッシュできない

以下のエラーメッセージが出た場合はこの対処法で多分大丈夫。

error: src refspec master does not match any
error: failed to push some refs to 'https://github.com/dev8-db/dev8-db-app'

ブランチを作成する

先ほどのエラーはブランチがありませんみたいな感じだったので、ブランチを作成します。
一応先ほどの.git/hooks/commit-msgファイルの内容を元通りにしておきました。しなくても大丈夫かもしれません。
これによりプッシュできるようになります。

git checkout -b new-branch-name
git push origin new-branch-name
このスクラップは14日前にクローズされました