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

Git 이야기

ROR Lab.
April 11, 2016

Git 이야기

ROR Lab.

April 11, 2016
Tweet

More Decks by ROR Lab.

Other Decks in Technology

Transcript

  1. History (FOFSBUJPO /FUXPSLJOH 0QFSBUJPOT $PODVSSFODZ &YBNQMFT 'JSTU /POF 0OFGJMFBUBUJNF -PDLT

    3$4 4$$4 4FDPOE $FOUSBMJ[FE .VMUJGJMF .FSHF CFGPSF DPNNJU $74 4PVSDF4BGF  4VCWFSTJPO  5FBN'PVOEBUJPO4FSWFS 5IJSE %JTUSJCVUFE $IBOHFTFUT $PNNJU CFGPSF NFSHF #B[BBS  (JU  .FSDVSJBM IUUQFSJDTJOLDPNWDCFIUNMIJTUPSZ@PG@WFSTJPO@DPOUSPMIUNM
  2. Version Control System •Centralized : CVS / SVN / Perforce

    •Distributed : Mercurial / Git / Bazaar IUUQCMPHTBUMBTTJBODPNWFSTJPODPOUSPMDFOUSBMJ[FEEWDT
  3. Version Control System •Centralized : CVS / SVN / Perforce

    •Distributed : Mercurial / Git / Bazaar POFSFQPTJUPSZ NVMUJQMFSFQPTJUPSJFT IUUQCMPHTBUMBTTJBODPNWFSTJPODPOUSPMDFOUSBMJ[FEEWDT
  4. D-VCS : git MPDBM SFQPTJUPSZ MPDBM SFQPTJUPSZ HJUIVC HJU HJU

    SFNPUF SFQPTJUPSZ DPNQBOZ SFQPTJUPSZ ѐߊ੗ ѐߊ੗
  5. D-VCS : git MPDBM SFQPTJUPSZ MPDBM SFQPTJUPSZ HJUIVC HJU HJU

    CJUCVDLFU HJUMBC SFNPUF SFQPTJUPSZ SFNPUF SFQPTJUPSZ DPNQBOZ SFQPTJUPSZ ѐߊ੗ ѐߊ੗
  6. 로컬 저장소 .git ├── HEAD ├── config ├── description ├──

    hooks │ ├── applypatch-msg.sample │ ├── commit-msg.sample │ ├── post-update.sample │ ├── pre-applypatch.sample │ ├── pre-commit.sample │ ├── pre-push.sample │ ├── pre-rebase.sample │ ├── prepare-commit-msg.sample │ └── update.sample ├── info │ └── exclude ├── objects │ ├── info │ └── pack └── refs ├── heads └── tags .git/
  7. Git 탈감작 : .gitignore # See https://help.github.com/articles/ignoring-files for more about

    ignoring files. # # If you find yourself ignoring temporary files generated by your text editor # or operating system, you probably want to add a global ignore instead: # git config --global core.excludesfile '~/.gitignore_global' # Ignore bundler config. /.bundle # Ignore the default SQLite database. /db/*.sqlite3 /db/*.sqlite3-journal # Ignore all logfiles and tempfiles. /log/* !/log/.keep /tmp IUUQTHJUTDNDPNEPDTHJUJHOPSF BMFBEJOHTMBTINBUDIFT UIFCFHJOOJOHPGUIFQBUIOBNF BOZXIFSFPSFWFSZUIJOH OFHBUF
  8. Git Radar NPEJGJFE VOUSBDUFE $ git add $ git rm

    $ git mv VONPEJGJFE $ git status DIFDLQPJOU DIFDLQPJOU
  9. Three States DPNNJUUFE NPEJGJFE TUBHFE MPDBM SFQPTJUPSZ 8PSLJOH EJSFDUPSZ 4UBHJOH

    "SFB HJUEJSFDUPSZ 3FQPTJUPSZ HJU HJUSFTFU HJUDIFDLPVU HJUSFWFSU HJUSFTFU
  10. Three States DPNNJUUFE NPEJGJFE TUBHFE HJUBEE MPDBM SFQPTJUPSZ 8PSLJOH EJSFDUPSZ

    4UBHJOH "SFB HJUEJSFDUPSZ 3FQPTJUPSZ HJU HJUSFTFU HJUDIFDLPVU HJUSFWFSU HJUSFTFU
  11. Three States DPNNJUUFE NPEJGJFE TUBHFE HJUDPNNJU HJUBEE MPDBM SFQPTJUPSZ 8PSLJOH

    EJSFDUPSZ 4UBHJOH "SFB HJUEJSFDUPSZ 3FQPTJUPSZ HJU HJUSFTFU HJUDIFDLPVU HJUSFWFSU HJUSFTFU
  12. Three States DPNNJUUFE NPEJGJFE TUBHFE HJUDPNNJU HJUBEE HJUSNDBDIFE ୶оஂࣗ HJUDIFDLPVU

    ߸҃ஂࣗ MPDBM SFQPTJUPSZ 8PSLJOH EJSFDUPSZ 4UBHJOH "SFB HJUEJSFDUPSZ 3FQPTJUPSZ HJU HJUSFTFU HJUDIFDLPVU HJUSFWFSU HJUSFTFU
  13. git add $ touch file1.txt $ echo “added some text”

    >> file1.txt OFXGJMF NPEJGJFEGJMF
  14. git rm $ rm $ git rm $ git rm

    --cached WT WT VOTUBHFE TUBHFE
  15. git rm $ rm $ git rm $ git rm

    --cached WT WT VOTUBHFE TUBHFE SFNPWFE SFNBJOFE
  16. git mv $ mv $ git mv WT $ mv

    README.txt README $ git rm README.txt $ git add README
  17. git mv $ mv $ git mv WT $ mv

    README.txt README $ git rm README.txt $ git add README VOTUBHFE TUBHFE
  18. Undo 3총사 요약 $PNNBOE 4DPQF $PNNPOVTFDBTFT HJUSFTFU $PNNJUMFWFM %JTDBSEDPNNJUTJOBQSJWBUFCSBODIPSUISPX BXBZVODPNNJUFEDIBOHFT

    'JMFMFWFM 6OTUBHFBGJMF HJUDIFDLPVU $PNNJUMFWFM 4XJUDICFUXFFOCSBODIFTPSJOTQFDUPME TOBQTIPUT 'JMFMFWFM %JTDBSEDIBOHFTJOUIFXPSLJOHEJSFDUPSZ HJUSFWFSU $PNNJUMFWFM 6OEPDPNNJUTJOBQVCMJDCSBODI 'JMFMFWFM /"
  19. Interactive rebase $ git rebase -i HEAD~3 pick 7e7e817 generated

    welcome#index pick eba707b added root route pick 379a01a scaffolded Post resource pick fc33700 generated Comment model pick 42de2aa listing all comments for a post pick 1110e42 added comment form view pick 7d66d67 added comments controller (#create, #destroy) pick ebc574e added comment delete functionality # Rebase 530681d..1312b24 onto 530681d (8 command(s)) # # Commands: # p, pick = use commit # r, reword = use commit, but edit the commit message # e, edit = use commit, but stop for amending # s, squash = use commit, but meld into previous commit # f, fixup = like "squash", but discard this commit's log message # x, exec = run command (the rest of the line) using shell
  20. Push HJUDPNNJU MPDBM SFQPTJUPSZ HJU DPNNJUUFE TUBHFE QVTIFE HJUIVC SFNPUF

    SFQPTJUPSZ HJUQVTI HJUEJSFDUPSZ 3FQPTJUPSZ 4UBHJOH "SFB (JUIVC 3FQPTJUPSZ
  21. Branching C1 C0 C2 NBTUFS )&"% EFWFMPQ C1 C0 C2

    NBTUFS )&"% EFWFMPQ C3 EFWFMPQ NBTUFS )&"% C3 C4 C1 C0 C2
  22. Unbranching(2) 3FCBTJOH EFWFMPQ NBTUFS C3 C4 C1 C0 C2 C3’

    SFCBTF  )&"% EFWFMPQ NBTUFS C4 C1 C0 C2 C3’ SFCBTF  )&"%
  23. Push to Local Repo $ git init test_repo $ git

    init --bare test_repo.git $ cd test_repo $ git remote add origin ../test_repo.git $ touch file1.txt $ git add file1.txt $ git commit -m “added file1.txt” $ git push -u origin master
  24. git alias $ git config --global 
 alias.lol “log --oneline

    --graph --decorate” $ watch -ct -n 1 'git status && echo && git lol'
  25. Merge Conflict ↟ #FZPOE$PNQBSF® ↟ IUUQTHJTUHJUIVCDPNKGSPNBOJFMMP $ git config --global

    diff.tool bc3 $ git config --global difftool.bc3 trustExitCode true $ git config --global merge.tool bc3 $ git config --global mergetool.bc3 trustExitCode true $ ln -s /usr/local/bin/bcomp /usr/local/bin/bc3 $ git mergetool / difftool