初期設定

# グローバル設定
$ git config --global
$ git config --system
$ git config --local

# リモートリポジトリの作成
$ mkdir hogehoge.git & cd hogehoge.git & git --bare init --shared

# リモートブランチを定義
$ git remote add origin git@bitbucket.org:<username>/hello_app.git

基本コマンド

# 初期化
$ git init

# リモートリポジトリを確認
$ git remote

# ローカルリポジトリを確認
$ git branch

# リモートのターゲットブランチを変更
$ git checkout

# ファイルの変更履歴を見る
$ git status

# リモートリポジトリのクローンを作成
$ git clone

# gitのコミット履歴を見る
$ git log
$ git log --graph --oneline -p --stat

# ステージングへ追加する
$ git add

# ステージングから下ろす
$ git reset HEAD

# ステージングをコミットする
$ git commit

# 変更コミットをリモートへアップロード
$ git push

# 変更コミットをローカルへダウンロード
$ git pull

# ローカルにリモートの更新を引っ張る
$ git fetch

# 別のブランチの変更をマージする
$ git merge

# 分岐点のベースを変える
$ git rebase branch_name

git branch & checkout options

# 全てのブランチ確認
$ git branch -a

# ブランチ作成
$ git branch <name>

# 作成&切り替え
$ git branch -b <name>

# 削除
$ git branch -d <name>

# リネーム
$ git branch -m <old> <new>

# リモートブランチをローカルへ
$ git branch <name> origin/<name>

# ブランチ切り替え
$ git checkout <name>

# ローカルへコピー&切り替え
$ git checkout <name> origin/<name>

# リモートブランチを削除する
$ git push —delete origin branch_name

コミットの操作

# 全ての変更をステージング
$ git add -a

# コメントを追加してコミット
$ git commit -m <name>

# 全てのファイルをコミット
$ git commit -a

# コミットメッセージ修正
$ git commit --amend -m

# 直前のコミットを戻す
$ git reset —soft Head^

# ワークツリーの変更を破棄して戻す
$ git reset --hard HEAD

# ??
$ git reflog

# 変更を退避する
$ git stash save

# 退避した作業の一覧を見る
$ git stash list

# 退避した作業を見る
$ git stash show stash@{0} -p

# 退避した作業を戻す
$ git stash apply stash@{0}

# 退避した作業を消す
$ git stash drop stash@{0}

# 退避した作業を元に戻す、stashのリストから消す
$ git stash pop stash@{0}

# 退避した作業をすべて消す
$ git stash clear

その他

# gitignoreの設定を反映させる
$ git rm -r --cached .
$ git add .
$ git commit -m ".gitignore is now working"
$ git push origin master

git-flow releace手順

// # 作業ブランチがfeatureの場合
// $

# 作業ブランチがreleaceの場合
$ npm run changelog
$ git add CHANGELOG.md && git commit -m 'v0.0.0 changelog'
$ git checkout master && git tag