commit
-
git commit
- コミット
-
git commit -m "[commit_message]"
- コミットメッセージを指定してコミット
-
git commit -a
- 追跡中のファイルの変更を全てコミット
-
git commit --allow-empty
- 空のコミット
push
-
git push
- ローカルのブランチの情報をリモートに反映(事前に設定が必要)
-
git push origin [local_branch]
- ローカルのブランチの情報をリモートに反映
-
git push -u origin [local_branch]
- 次回以降のためにローカルとリモートのブランチの紐付けを行い、ローカルのブランチの情報をリモートに反映
-
git push --delete origin [remote_branch]
- リモートに存在するブランチを削除
pull
-
git pull
- リモートのブランチの情報を取得してマージ
fetch
-
git fetch
- リモートのブランチの情報を取得
merge
-
git merge
- リモートのブランチをローカルにマージ
-
git merge [other_branch]
- 他のブランチを現在のブランチにマージ
-
git merge --squash [other_branch]
- 他のブランチの変更を一つにまとめて現在のブランチにマージ
checkout
-
git checkout [local_branch]
- ローカルに存在するブランチにチェックアウト
-
git checkout -b [local_branch] origin/[remote_branch]
- リモートに存在するブランチをローカルに新規作成してチェックアウト
-
git checkout -b [local_branch-2] [local_branch-1]
- ブランチ1をブランチ2として新規作成してチェックアウト
branch
-
git branch
- ローカルに存在するブランチを表示
-
git branch -a
- ローカルとリモートに存在するブランチを表示
-
git branch --color
- ブランチを色を付けて表示
-
git branch -D [local_branch]
- ローカルに存在するブランチの削除
reset
-
git reset --soft HEAD^
- ファイルの内容はそのまま、直前のコミットを取り消す
-
git reset --hard HEAD^
- ファイルの内容も含めて、直前のコミットを取り消す
追記
コマンドの追加
作業フォルダ内に、.git
という隠しフォルダがあると思います。
このフォルダの中に、config
というファイルがあります。
このファイルが、その名の通り設定ファイルです。
このファイル内に、[alias]
と書いて、その後にgit
の後に続くコマンドを書けば、そのコマンドを使うことができるようになります。
[alias]
graph = log --graph --date-order -C -M --pretty=format:\"<%h> %ad [%an] %Cgreen%d%Creset %s\" --all --date=short
因みに、上のはgitのツリー構造を表示するためのコマンドです。
dev
の変更をmaster
に反映
git checkout master
git merge --squash dev
git commit -m "[commit_message]"
git push
master
ブランチに コミットの数を増やしたくない場合 はこう?
まぁ、普通は別ブランチにダウンロード用のものを作成して行うかな?
その場合は、master
を[download_branch]
に変更!
けど、これだとgitのツリー構造が繋がってくれないんだよなー。
誰かツリー構造が繋がってくれる、もっと良い方法を教えてください!