Upgrade to Pro — share decks privately, control downloads, hide ads and more …

GIT中級者への道

Sponsored · SiteGround - Reliable hosting with speed, security, and support you can count on.
Avatar for kkkw kkkw
August 29, 2018

 GIT中級者への道

Avatar for kkkw

kkkw

August 29, 2018
Tweet

More Decks by kkkw

Other Decks in Programming

Transcript

  1. 例 例 下記の2 つは同じ意味 git merge origin/master git log origin/master

    // 先頭のコミットハッシュがxxxxx だとする git merge xxxxx
  2. git add -p git add -p // このhunk をステージする y

    - stage this hunk // このhunk はステージしない n - do not stage this hunk // これ移行の hunk をステージしない q - quit; do not stage this hunk or any of the remaining ones // これ移行すべてをステージ a - stage this hunk and all later hunks in the file // このファイルのhunk はこれ移行すべてステージ d - do not stage this hunk or any of the later hunks in the file // 指定した hunk に移動 g - select a hunk to go to // マッチするhunk を検索 / - search for a hunk matching the given regex // いったんスキップ。次の未解決のhunk を表示 j - leave this hunk undecided see next undecided hunk
  3. commit のオプション commit のオプション a 管理下にあるファイル変更点を全て含めてコミッ ト。新規ファイルでステージングもされていない ものは入らない p add

    と同じ c 指定したコミットと同じメッセージを使う git commit -c HEAD v コミットしようとする内容を表示する
  4. log のオプション log のオプション n 数を指定 -1 とかで代用可 特定のパス git

    grep -- foo/bar/buz S 変更の差分でgrep git log -S"foo" --pretty=oneline --name-only
  5. stash のオプション stash のオプション p add と同じ a all git

    管理されていないファイルも含める
  6. reset のオプション reset のオプション --soft ステージングには残す -- hard working tree

    からも消す default ステージングから消して、working tree には残す
  7. マージコミットの マージコミットの リバートの考え方 リバートの考え方 マージコミットには、歴史が2 つある m に指定するの は、どちらの歴史が正しいか。 1

    つ目はマージされた側 github ow だと、大抵master のHEAD 2 つ目はマージする側 github ow だと、大抵PR のブランチのHEAD なので大抵1 を指定することになる
  8. github ow でありがちな状況 github ow でありがちな状況 feature/bar の git log

    --oneline 左端はコミットハッシュ こんな感じで指定する bar-ci-3 (HEAD -> feature/bar, origin/feature/bar) some bar comme bar-ci-2 some bar comment 2 bar-ci-1 some bar comment 1 pr-3-ci (origin/master, origin/HEAD, master) Merge pull request # pr-2-ci Merge pull request #2 from feature/some-pr-2 pr-1-ci Merge pull request #1 from feature/some-pr-1 git checkout future-bar git log --oneline // 派生元のコミットハッシュを見つける git rebase --onto master pr-3-ci // コミットハッシュか派生元ブランチを指