Why not login to Qiita and try out its useful features?

We'll deliver articles that match you.

You can read useful information later.

8
7

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.

[vscode] git initしたのに「現在開いているフォルダーにはgitリポジトリがありません」とソースコントロールで表示されたら

Posted at

発生事象

新規開発しようとしてgit init実行後に対象ディレクトリをvscodeで開いたところ、ソース管理に 現在開いているフォルダーには Git リポジトリがありません。Git を利用したソース管理機能を有効にするリポジトリを初期化できます。 という文言が表示されていた。
git initは実行ずみなので、「リポジトリを初期化する」をクリックしても、すでにinitされているというエラーが発生。

ぶっちゃけGUIでgit操作はしないけど、vscodeの左下に現在のブランチ名が表示されないのが地味に辛いと感じたので対応しました。

スクリーンショット 2021-02-10 0.47.13.png

解決方法

※以下の手順は直接settings.jsonを開いて設定した方が楽です。

  1. which gitを実行して結果をコピーしておく。私の環境では/usr/local/bin/gitでした。
  2. 設定の検索窓にgit.pathを入力すると以下のような項目が表示されるので、 settings.jsonで編集 を選択する。
    スクリーンショット 2021-02-10 0.55.31.png
  3. settings.jsongit.pathに先ほどコピーしたgitのパスを設定する。
    スクリーンショット 2021-02-10 0.55.47.png
  4. vscodeをリロードするとソース管理がリポジトリを認識するようになり、ソース管理からのgit操作が可能になる。

上記手順実行後に無事ソース管理がgitリポジトリを認識し、現在のブランチがvscodeの左下に表示されるようになりました。

8
7
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

Qiita Conference 2025 will be held!: 4/23(wed) - 4/25(Fri)

Qiita Conference is the largest tech conference in Qiita!

Keynote Speaker

ymrl、Masanobu Naruse, Takeshi Kano, Junichi Ito, uhyo, Hiroshi Tokumaru, MinoDriven, Minorun, Hiroyuki Sakuraba, tenntenn, drken, konifar

View event details
8
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?