インストール
ダウンロード先(win):https://git-scm.com/download/win
コンソール起動
C:\Program Files\Git\git-bash.exe
バージョン確認
$ git --version git version 2.12.2.windows.2
初期設定
ユーザ名・メールアドレス登録
$ git config --global user.name "hoge" $ git config --global user.email "hoge@fuga.com"
出力のカラーリング
デフォルト設定
$ git config --global color.ui true
リポジトリ作成
$ mkdir gitTest $ cd gitTest $ git init Initialized empty Git repository in C:/Users/sk/gitTest/.git/
ファイルをコミット
ディレクトリに新しいファイルを追加
$ vim test.html # 適当にテキストを記述、保存 :qw
参考 vim
- インストール:https://www.kaoriya.net/software/vim/
- パス追加(保存先指定):C:\Program Files (x86)\vim
- undofile 無視設定:.gitignore
.*.un~
ディレクトリの確認
$ git status
On branch master
Initial commit
Untracked files:
(use "git add <file>..." to include in what will be committed)
test.html
nothing added to commit but untracked files present (use "git add" to track)
ファイルをインデックスに追加
$ git add test.html
# またはファイルすべて
$ git add .
git status
On branch master
Initial commit
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: test.html
ファイルをコミット
$ git commit -m "最初のコミット" [master (root-commit) e97cb9a] 最初のコミット 1 file changed, 3 insertions(+) create mode 100644 test.html $ git status On branch master nothing to commit, working tree clean
リポジトリの変更履歴確認
$ git log
commit e97cb9a719d15f9f5ec50d92c86a2f676d5b79c2
Author: hoge <hoge@fuga.com>
Date: Sun Apr 9 21:39:56 2017 +0900
最初のコミット
# 終了
q
GUI
gitk
日本語文字化け対策
git config --global gui.encoding utf-8参考:gitkのエンコーディングを設定する https://www.pistolfly.com/weblog/2010/02/gitk.html