Skip to content

Instantly share code, notes, and snippets.

@KentarouKanno
Last active May 6, 2017 21:54
Show Gist options
  • Save KentarouKanno/7706695521acec74ad6cbc1b30eb63f2 to your computer and use it in GitHub Desktop.
Save KentarouKanno/7706695521acec74ad6cbc1b30eb63f2 to your computer and use it in GitHub Desktop.

Git command

git init

コマンド 処理 使用例
git init カレントディレクトリを Git リポジトリに変換します。

git add

コマンド 処理 使用例
git --version Gitのバージョンを確認
git config --global user.name 'Name' Gitのグローバルな名前を設定する
User/.gitconfigの中の[User]のname=
git config --global user.email 'Email Address' GitのグローバルなEmailを設定する

git log

コマンド 処理 使用例
git log コミットログを確認
git log -p ファイルの差分も一緒に表示する
git log --graph ブランチを視覚的に確認する
git log --pretty=short コミットメッセージの1行目のみを表示する

git checkout

コマンド 処理 使用例
git checkout - 一つ前のブランチに切り替える

git commit

コマンド 処理 使用例
git commit commitする viが起動してコミットメッセージを入力する
git commit -m "コミットメッセージ" commitにコミットメッセージを付ける
git commit -m "close #8" コミットと同時にissuesをcloseする

フォーマットは下に記述
複数記入する場合
This commit fix #8, fix #9, fix #10
git commit -m "Add feature #24" 対象の Issue にこのコミット情報が表示される。
git commit -am "Add files" git add と git commit を同時に行う
git commit --amend 直前のコミットメッセージを修正する

git commit message でissuesをクローズする時のフォーマット

フォーマット一覧 記載方法
fix fix #8
fixes This commit fixes #8
fixed We have finally fixed #8
close close #8
closes This closes #8
resolve resolve #8
resolves resolves #8
resolved resolved #8

fixes #8 = 「このコミットで #8 を 修正する」
fixed #8 = 「このコミットで #8 を 修正した」

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment