|
gitの初期設定 |
|
config |
ユーザ名を設定 |
$ git config --global user.name "[name]" |
config |
Eメールを設定 |
$ git config --global user.email "[email address]" |
init |
リポジトリを作成 |
$ git init "[project-name]" |
clone |
クローンする |
$ git clone "[url]" |
|
コミット |
|
status |
変更ファイルを一覧表示(コミット前) |
$ git status |
diff |
未ステージングファイルの差分表示 |
$ git diff |
add |
ステージにあげる |
$ git add "[file]" |
diff |
ステージとの差分を表示 |
$ git diff --staged |
reset |
アンステージ(内容は保存) |
$ git reset "[file]" |
commit |
コミット |
$ git commit -m "[コミットメッセージ]" |
|
ブランチ操作 |
|
branch |
ブランチ作成 |
$ git branch "[branch-name]" |
checkout |
指定されたブランチに切り替えて作業ディレクトリを更新 |
$ git checkout "[branch-name]" |
merge |
ブランチをマージ |
$ git merge "[branch]" |
branch |
ブランチを削除 |
$ git branch -d "[branch-name]" |
rm |
ファイルを削除 |
$ git rm "[file]" |
rm |
バージョン管理からファイルを削除 (ファイルをローカルに保存) |
$ git rm --cached "[file]" |
mv |
ファイル名を変更し、コミットを準備 |
$ git mv "[file-original]" "[file-renamed]" |
ls-files |
ignoredファイルの一覧を表示 |
$ git ls-files --other --ignored --exclude-standard |
stash |
変更されたすべてのファイルを一時的に保存 |
$ git stash |
stash |
最新の一時保存したファイルを復元 |
$ git stash pop |
stash |
一時保存したすべてのファイル一覧を表示 |
$ git stash list |
stash |
最後に一時保存したファイルを削除 |
$ git stash drop |
log |
現在のgitの履歴を一覧表示 |
$ git log |
log |
ファイルのバージョン履歴をリネームも含めて表示 |
$ git log --follow "[file]" |
diff |
2つのブランチ間の差分を表示 |
$ git diff "[first-branch]...[second-branch]" |
show |
指定されたコミットのメタデータとコンテンツの変更を出力。 |
$ git show "[commit id]" |
reset |
[commit]の後にすべてのコミットを元に戻し、ローカルに変更を保存 |
# git reset "[commit id]" |
reset |
すべての履歴と変更を破棄 |
# git reset --hard "[commit id]" |
fetch |
リモートリポジトリからすべての履歴をダウンロード |
$ git fetch "[origin]" |
merge |
リモートリポジトリのブランチを現在のローカルブランチに結合 |
$ git merge "[origin]"/"[branch]" |
push |
ブランチをすべてアップロードローカルブランチはGitHubにコミット |
$ git push "[origin]" "[branch]" |
pull |
リモートリポジトリの履歴をダウンロードし、変更を組み込む |
$ git pull |