LoginSignup
0
0

More than 1 year has passed since last update.

error: 'dir/' does not have a commit checked outの解決法

Posted at

背景

git add .しようとしたらエラーが発生した

❯ git add .
error: 'dir/' does not have a commit checked out
fatal: adding files failed

解決方法を探してみる

以下の記事に書いてあった。
.gitが2つあってそれが原因らしい...?

VScode上で探しても見つからない...

勘違いしていた

.gitはファイルのことではなく、.git/ディレクトリのことだったみたい。

# エラーで指摘されている`dir/`に移動してからls -a
.              .git           Dockerfile     README.md      bin            db             public         tmp
..             .gitattributes Gemfile        Rakefile       config         lib            storage        vendor
.env           .ruby-version  Gemfile.lock   app            config.ru      log            test

...あった! .gitを消してみる

❯ rm -rf .git
❯ git add .

エラーが出なくなった!解決!

まとめ

  • .gitがディレクトリのことだった(Gitの基礎を理解していればハマらないことだったのかも...?)
  • エディタ上で見つけられない時はターミナルなどのCLIで確認してみるのも良いかも
0
0
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
0
0