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

Git

 Git

Avatar for backup

backup

July 18, 2017
Tweet

Other Decks in Technology

Transcript

  1. a.k.a Eddie Ruby/Rails/iOS app 開發者、講師 Ruby 技術推廣、教育、諮詢 台灣、⽇日本 Ruby 技術研討會講者

    ⽬目前於五倍紅寶⽯石擔任紅寶⽯石鑑定商職務 部落落格:http://kaochenlong.com ⾼高⾒見見龍 photo by Eddie @eddiekao
  2. photo by Eddie ⽇日本 Ruby 認證開發者 (2012/1). Adobe 原廠認證 Flash

    開發者 (2006/7). Linux LPI 國際認證 (2005/3). 五倍紅寶⽯石共同創辦⼈人 台灣 WebConf、PHPConf 發起⼈人 Rails Girls Taipei 發起⼈人 PTT Flash 版版主 a.k.a Eddie ⾼高⾒見見龍 @eddiekao
  3. )KV

  4. Mac: $ brew install git Ubuntu or some linux OS:

    $ sudo apt-get install git-core or $ sudo apt-get install git
  5. ㇛䶬䧏日 $ mkdir demo ⓾瘟甙 $ cd demo $ git

    init Initialized empty Git repository in / private/tmp/demo/.git/
  6. 㦌⸹☡⫀
 5VCIKPI#TGC テ∽䧏日
 9QTMKPI&KTGEVQT[ ␓⸹ㆌ 㨍⨑ 
 4GRQUKVQT[ IKVCFF IKVEQOOKV

    IKVTGUGV IKVTOECEJGF ␓⸹ㆌ 肈䷐ 
 4GRQUKVQT[ IKVRWUJ IKVRWNN
  7. 㫆䧬䖡㐬 $ git status Initial commit Changes to be committed:

    (use "git rm --cached <file>..." to unstage) new file: index.html
  8. 㚱ↅ $ git commit -m "add index.html" [master (root-commit) cb96971]

    add index.html 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 index.html
  9. 0QTOCN +PUGTV '5% QT EVTN = KKPUGTV CCRRGPF QPGYNKPG Y⸹㵵

    S腩桬 YS⸹㵵竅砒腩桬 恦侟伂8KO↬倚
  10. ⃮㏔䠉櫱崎䥥紉成⥉! emacs: $ git config --global core.editor emacs
 sublime text:

    $ git config --global core.editor "subl -n -w" atom: $ git config --global core.editor "atom --wait"
  11. 年䧏┮䥥䧏日⦿┑⃫⃡禈䥥EQOOKV $ git checkout . $ git clean -f $

    git clean -df # d = 清除⽬目錄 䃦楅WPVTCEM䖡㐬䥥㵵礌
  12. 㢑⭿ⓧ㠐ECV $ git branch cat 㶃屷ⓧ㠐 $ git branch cat

    * master $ git branch -d cat Deleted branch cat (was cb96971). ┋楅ⓧ㠐ECV
  13. 璶㠚㚱ↅ $ git rebase -i cb96971 # 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
  14. ⃫⎔ $ git push origin master $ git push origin

    cat ⃫⎔ECVⓧ㠐┑QTKIKP亡熿
  15. ⛩≖㪱⋬箞⹻亡熿 $ git cherry-pick 823520ed $ git cherry-pick 823520ed --edit

    ⛩≖㪱⋬箞⹻亡熿┮紉成峫㍐ $ git cherry-pick 823520ed --no-commit 甩㉸㪱⋬箞⹻亡熿⑈⺚∧⃮聜嬭⛩≖
  16. UVGR㢑⭿⚀≧TGRQ䥥肈䷐亡熿 $ git remote add upstream ORIGIN_REPO $ git fetch

    upstream UVGR甩㉸嵓亡熿㵵礌 $ git merge upstream/master UVGR⛩≖
  17. 㦌⸹☡⫀
 5VCIKPI#TGC テ∽䧏日
 9QTMKPI&KTGEVQT[ ␓⸹ㆌ 㨍⨑ 
 4GRQUKVQT[ IKVCFF IKVEQOOKV

    IKVTGUGV IKVTOECEJGF ␓⸹ㆌ 肈䷐ 
 4GRQUKVQT[ IKVRWUJ IKVRWNN $ git config --global user.name "5xruby" $ git config --global user.email "[email protected]" 崎⹻獌 $ git init ⓾瘟甙獌 $ git add FILENAME 㕫㵵礌▁┑㦌⸹☡⫀獌 $ git status 㫆䧬䖡㐬獌 $ git commit -m "add index.html" 㚱ↅ獌 $ git log 㶃屷信日獌 $ git reset HEAD^ 甩䁩磷砒⃡禈㚱ↅ獌 $ git branch 5xruby 㢑⭿ⓧ㠐5xruby獌 $ git branch 㶃屷䧏┮ⓧ㠐獌 $ git branch -d 5xruby ┋楅ビ⛩≖ⓧ㠐5xruby獌 $ git checkout 5xruby ⓨ碍ⓧ㠐┑5xruby獌 $ git merge 5xruby ⛩≖ⓧ㠐5xruby獌 $ git remote add origin REMOTE_URL 㢑⭿肈䷐亡熿origin獌 $ git remote -v 㶃屷肈䷐亡熿獌 $ git remote rm origin ┋楅肈䷐亡熿origin獌 $ git push origin master 㕫masterⓧ㠐⑈⺚㚉㉡origin亡熿獌 $ git pull origin master 㕫肈䷐origin亡熿䥥master㖪⦿㨍祚ℇ聜嬭⛩≖獌