git初期化
リポジトリの作成
# Gitリポジトリの作成 $ git init Initialized empty Git repository in /Users/owner/mysite/blog/.git/ # カレントディレクトリに.gitディレクトリが作られる $ ls -l .git total 24 -rw-r--r-- 1 owner staff 23 5 22 19:01 HEAD -rw-r--r-- 1 owner staff 137 5 22 19:01 config -rw-r--r-- 1 owner staff 73 5 22 19:01 description drwxr-xr-x 14 owner staff 448 5 22 19:01 hooks drwxr-xr-x 3 owner staff 96 5 22 19:01 info drwxr-xr-x 4 owner staff 128 5 22 19:01 objects drwxr-xr-x 4 owner staff 128 5 22 19:01 refs #現在の状態を確認 $ git status On branch master No commits yet nothing to commit (create/copy files and use "git add" to track
これでgitリポジトリが作成されたのでこれを元に設定をする
Git設定
Gitで操作を行う前にユーザー情報を紐づける必要があり、まずは設定情報を確認する
# 設定情報の確認 $ git config --list
ここで確認したい情報はuser.email
とuser.name
で、この二つがユーザーを特定するため必ず必要な情報
# メールアドレスを設定する(GitHubに登録するメールアドレスと同じものを使う) $ git config --global user.email your-email@example.com # ユーザー名 $ git config --global user.name 'your name' # 設定の確認 $ git config --list user.email=your-email@example.com user.name=your name
使用したコマンド
git init
Gitリポジトリを新しく作るためのコマンド
このコマンドを実行することで.gitディレクトリができる
.gitディレクトリにはGit関連の様々のファイルが格納されている
git status
現在のGitの状態を表示するコマンド。
このコマンドで以下のようなことが分かる。
現在いるブランチ(例: On branch master)
ファイルの状態変化(編集やインデックスへの追加など)