15
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

gitブランチを作成しようとしたら『fatal: 'origin/ブランチ名' is not a commit and a branch 'ブランチ名' cannot be created from it』となった

Last updated at Posted at 2019-12-31

事象

下記のようなgit環境がある。

$ git branch -a
* master
  remotes/origin/feature
  remotes/origin/master

ここで、git checkoutコマンドでorigin/featureからfeatureブランチを作成してチェックアウトしようとしたら下記のようなエラーとなった。

$ git checkout -b faeture origin/faeture
fatal: 'origin/faeture' is not a commit and a branch 'faeture' cannot be created from it

解決

ブランチ名のtypoだった。エラーも「リモートにそんなコミットはないからブランチは作られなかったよ」と言っている。

  • 誤:git checkout -b faeture origin/faeture
  • 正:git checkout -b feature origin/feature
$ git checkout -b feature origin/feature                      
Branch feature set up to track remote branch feature from origin.
Switched to a new branch 'feature'

チェックアウトできた。

以上

15
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
15
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?