$ git init
$ rm -rf .git
$ git add file/dir
ディレクトリを指定すると、それ以下のファイルをすべて追加する
スペースで区切って複数のファイルを指定することもできる
$ git commit
Vimが起動するのでコメントを入力して保存する
-a | add してからcommit する
|
-m "comment" | Vimを起動せずにコメントを書く |
--amend | 直前のcommitに上書きする |
$ git log
-p | 変更箇所を表示 |
--stat | 変更されたファイル名・変更箇所数を表示 |
--oneline | 1行で表示 |
$ git show commitID/HEAD[:file]
--pretty=fuller | 詳細表示 |
$ git status
-s | 詳細を非表示 |
-b | -s をつけたときにブランチ名を表示
|
$ git diff
$ git diff --cached
$ git diff HEAD
$ git difftool
$ git reset --soft commitID
add
を取り消す)$ git reset HEAD
$ git reset commitID
$ git reset --hard HEAD
$ git reset --hard commitID
reset
(コミットの巻き戻し)を取り消す$ git reset --hard ORIG_HEAD
$ git checkout -- file
$ git rm file
$ git mv file dir/new_file
$ git branch branch_name
引数を未指定の場合、ブランチ一覧が表示される
現在のブランチを元に複製される
-d | ブランチを削除 |
$ git checkout branch_name
-b | ブランチが存在しない場合、作成してから切り替え |
$ git merge from_branch
$ git mergetool
$ git tag tag_name commitID
commitID
省略時:HEAD
-d tag_name | タグを削除 |
$ git init --bare
$ git remote add name url/path
$ git remote rm name
$ git push remote local_branch
$ git pull remote local_branch
$ git clone url/path dir
$ git fetch remote
最新情報を取得する
git diff
やgit log
などはFETCH_HEAD
で取得できる
$ git config --global user.name "Name"
$ git config --global user.email "example@example.com"
$ git config --global color.ui always
$ git config --global mergetool.keepBackup false
$ git config --global alias.alias_name alias_command
$ git config -l
$ vim .gitignore
ワイルドカード(*
)も使用できる
$ touch .gitkeep
適当なファイルを置く必要がある
ファイルの変更履歴を保存する場所
コミット前のファイルの一時保管場所
ファイルがあるディレクトリ
最終コミット
© 2019 shge.github.io 利用規約・プライバシー