2013年2月25日月曜日

git まとめ

gitを使ってみて良く使うことだけをまとめる

git --help

git コマンド一覧がでてくる

git command --help

git コマンドごとの詳しい説明がでてくる
でも、英語なので、ここで理解できずにggrことになる

git clone

git clone git@github.com:yanap/dotfiles.git
リポジトリを自分のパソコンにダウンロードする

git add

新規作成したファイルをgitに追加する

git commit

その時点での進捗具合をセーブす的なコマンド
セーブした所にすぐ戻れる

git commit -a

addを同時に行う

git commit -a -m "comment"

addとコメント入力を同時に行う

git commit -a -m "comment" --dry-run

ドライラン

git commit --amend

セーブするポイントを間違えたときにセーブを上書きする

git push origin [local<branch>]:[remote<branch>]

git push origin dev:dev

local branch : remote branch

でも、普段はlocal branchは省略しても大丈夫なので
git push origin dev

remote branchを消したいときは
git push origin :delete_branch
NULL:delete_branch
NULLを対象のremote branchにpushするので、指定された
remote branchは削除される

git checkout

git checkout [<branch>]

git checkout master 作業環境をmasterに変える
git checkout dev 作業環境をdevに変える

git checkout -b [<branch>]

ブランチ作成とブランチ切り替えを同時に行う

git checkout -t origin/[<branch>]

リモートにあるブランチをローカルにダウンロードすると同時に
ブランチを切り替える。

git pull origin [remote <branch>]

remoteのbranchをダウンロードしてlocalのbranchにマージする
git pull origin devはgit fetach origin dev
してgit merge origin dev している





0 件のコメント:

コメントを投稿