最終更新:2016-01-13 (水) 16:27:58 (3023d)  

git
Top / git

インデックス

  • コミットするファイルを保持しておくキャッシュ。

ファイル

  • インデックスとリポジトリは.gitディレクトリ内に存在

よく使われるコマンド

  • Git/コマンド
    コマンド説明
    git addAdd file contents to the index
    git bisectFind by binary search the change that introduced a bug
    git branchList, create, or delete branches
    git checkoutCheckout a branch or paths to the working tree
    git cloneClone a repository into a new directory
    git commitRecord changes to the repository
    git diffShow changes between commits, commit and working tree, etc
    git fetchDownload objects and refs from another repository
    git grep?Print lines matching a pattern
    git initCreate an empty Git repository or reinitialize an existing one
    git logShow commit logs
    git mergeJoin two or more development histories together
    git mvMove or rename a file, a directory, or a symlink
    git pullFetch from and integrate with another repository or a local branch
    git pushUpdate remote refs along with associated objects
    git rebaseForward-port local commits to the updated upstream head
    git resetReset current HEAD to the specified state
    git rmRemove files from the working tree and from the index
    git showShow various types of objects
    git statusShow the working tree status
    git tagCreate, list, delete or verify a tag object signed with GPG

基本

  • コマンド説明
    ■リポジトリの作成およびメンテナンスに利用するコマンド
    git initリポジトリを作成する
    git clone {repo}既存のリポジトリの複製を作る
    git clone {oldrepo} {newrepo}リポジトリをコピー
    git fsck?リポジトリの正当性チェックを行う
    git gc?リポジトリ内の不要なオブジェクトを削除し、最適化を行う
    ■作業ツリーやブランチを操作・管理するコマンド
    git status変更が加えられたファイルを表示する
    git diffファイルに加えられた変更点をdiff形式で表示する
    git diff --cachedインデックスに追加したものの差分
    git diff {branchname}ブランチとの差分
    git add {file/dir}コミットするファイルを指定(ファイルをインデックスに追加)
    git commit -m "comment"変更点をコミットする
    git commit -a -m "comment"-aオプションは、変更したファイルを自動的にgit addします
    git logコミットログを表示
    git reset直前のコミットを取り消す
    git revert作業ツリーを指定したコミット時点の状態にまで戻す
    git branch現在のブランチの確認
    git branch {branchname}ブランチの作成
    git checkout {branchname}ブランチの切り替え
    git show-branch?ブランチの作成/変更/マージ履歴を表示
    git merge {branchname}ローカルブランチのマージを行う
    git tagコミットにタグを付ける
    git stash現在の作業ツリーの状態を一時的に保管する
    git rebaseブランチの派生元(上流)を変更する
    ■ほかのリポジトリとの連携を行うコマンド
    git pullほかのリポジトリの変更点をローカルリポジトリにマージする
    git push公開リポジトリに自分のリポジトリの内容を送信する
git show
git grep

共同開発

git pull {repo} {branch} #repoで行われた変更をbranchにマージ
git fetch {repo} {branch} #マージする前に様子見
git log -p HEAD..FEACH_HEAD
git remote 

名前

  • ORIG_HEAD - コミットされていた内容
  • HEAD - 現在のバージョン
  • HEAD^ - 一つ前のバージョン
  • HEAD^^ - 2つ前のバージョン

関連

参考