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

git switch & git restore

4a05d4c03e5f9c6f78ec4b3c57dc63c4?s=47 oohira
January 21, 2020

git switch & git restore

4a05d4c03e5f9c6f78ec4b3c57dc63c4?s=128

oohira

January 21, 2020
Tweet

Transcript

  1. switch & restore ϏΞόογϡେฏ௚޺ !PPIJSB

  2. 4VCKFDU<"//06/$&>(JUW 'SPN+VOJP$)BNBOPHJUTUFS!QPCPYDPN %BUF'SJ "VH 2  5XPOFXDPNNBOETHJUTXJUDIBOEHJUSFTUPSFBSFJOUSPEVDFEUP TQMJUDIFDLJOHPVUBCSBODIUPXPSLPOBEWBODJOHJUTIJTUPSZBOE DIFDLJOHPVUQBUITPVUPGUIFJOEFYBOEPSBUSFFJTIUPXPSLPO BEWBODJOHUIFDVSSFOUIJTUPSZPVUPGUIFTJOHMFHJUDIFDLPVU

    DPNNBOE
  3. • HJUTXJUDI • ϒϥϯνΛมߋ͢Δૢ࡞ • HJUSFTUPSF • ϑΝΠϧΛมߋ͢Δૢ࡞ ˞·ͩFYQFSJNFOUBMɻHJUDIFDLPVU΋࢖͑Δ 3

    HJUDIFDLPVU͸੹຿͕େ͖͍͔Β෼ׂ
  4. • ϒϥϯνͷ੾Γସ͑ • ϒϥϯνͷ࡞੒ˍ੾Γସ͑ • ͭલͷϒϥϯνʹ໭Δ 4 HJUTXJUDI $ git

    switch topic # git checkout topic $ git switch -c topic # git checkout -b topic $ git switch - # git checkout -
  5. • ϑΝΠϧͷϩʔΧϧͷमਖ਼Λ໭͢ • ϑΝΠϧΛಛఆͷίϛοτʹ໭͢ 5 HJUSFTUPSF  $ git restore

    README # git checkout -- README $ git restore --source <commit> README # git checkout <commit> -- README
  6. • εςʔδϯάΤϦΞʹ͋ΔϑΝΠϧΛ໭͢ • εςʔδϯάΤϦΞ΋ϩʔΧϧ΋໭͢ 6 HJUSFTUPSF  $ git restore

    --staged README # git reset README $ git restore --source HEAD --staged --worktree README # git reset --hard README
  7. 7 ઈରDPͷํ͕ଧͪ΍͍͢ $ vi ~/.gitconfig ... [alias] co = checkout

    sw = switch
  8. • )JHIMJHIUTGSPN(JU5IF(JU)VC#MPH • IUUQTHJUIVCCMPH IJHIMJHIUTGSPNHJU • (JUHJUTXJUDI%PDVNFOUBUJPO • IUUQTHJUTDNDPNEPDTHJUTXJUDI •

    (JUHJUSFTUPSF%PDVNFOUBUJPO • IUUQTHJUTDNDPNEPDTHJUSFTUPSF 8 ࢀߟจݙ