Gitで新規ローカルリポジトリを作成する方法

作業プロジェクトフォルダに移動して、次のコマンドを実行します。

git init

コマンドを実行すると、.gitディレクトリが作成され、以下が作成されます。

  • リポジトリ(圧縮ファイル・ツリーファイル・コミットファイル)
  • インデックスファイル
  • 設定ファイル

コマンドを実行した後には、次のような返答があります。

hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint: 
hint: 	git config --global init.defaultBranch <name>
hint: 
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint: 
hint: 	git branch -m <name>
Initialized empty Git repository in /Users/xxx/Documents/git_tutorial/.git/

空のGitリポジトリが初期化されたと記載があります。

作成された.gitディレクトリに、何があるのか確認してみます。次のコマンドを実行します。

ls .git/

すると、次のような返答がありました。

目次