git がブランチを切り替えるときのエラーの解決策 (エラー: pathspec 'master' が git に認識されているどのファイルにも一致しませんでした。)

ブランチ切り替え時の git エラー

ブランチを切り替える:

[root@git my_code]# git checkout master

次のエラーが生成されます。

error: pathspec 'master' did not match any file(s) known to git.

解決:

1. ブランチのステータスを確認します。

[root@git my_code]# git branch -a
ここに画像の説明を挿入します

2. 必要なブランチが見つからない場合は、まずすべてのブランチを取得します。

[root@git my_code]# git fetch
ここに画像の説明を挿入します

3. この時点で分岐状況を再度確認します

[root@git my_code]# git branch -a
ここに画像の説明を挿入します
目的のブランチが表示されていることがわかります

4. ブランチを切り替える

[root@git my_code]# git checkout master
[root@git my_code]# git branch --list
ここに画像の説明を挿入します
この時点で、分岐の切り替えは成功し、問題は解決されます。

おすすめ

転載: blog.csdn.net/weixin_44178770/article/details/124830279
おすすめ