Git, Github, and Vim

Git, Github, and Vim

a short training course for Ruby/Rails newcomer

F2dcf6633971844e19ca96ea294ba976?s=128

高見龍

April 06, 2013
Tweet

Transcript

  1. 2.
  2. 4.

    Git

  3. 11.
  4. 12.
  5. 17.

    on Mac: > brew install git on Ubuntu or some

    linux OS: > sudo apt-get install git-core
  6. 21.
  7. 22.
  8. 23.
  9. 26.
  10. 30.

    Exercise: try to check if "hello.rb" is in staging area,

    and then remove it from staging area.
  11. 31.
  12. 38.

    Exercise: in last commit, you forgot to add another file,

    but you don't want to commit again just for this single file, please try to commit it with -- amend.
  13. 40.
  14. 43.
  15. 45.
  16. 50.

    Exercise: 1. create a new branch name "fruit" 2. checkout

    to "fruit" branch 3. add a "banana.rb" and commit it
  17. 53.
  18. 55.

    Exercise: 1. checkout back to "master" branch 2. merge "fruit"

    to "master" 3. remove "fruit" branch if you like
  19. 59.
  20. 60.
  21. 65.

    set your username and email > git config --global user.name

    "eddie" > git config --global user.email "eddie@digik.com.tw" list all settings > git config --list
  22. 67.

    Exercise: 1. set your username and email for git. 2.

    edit the ".gitconfig" and add some aliases.
  23. 71.
  24. 73.

    on Mac: > brew install git-flow on Ubuntu or some

    linux OS: > sudo apt-get install git-flow https://github.com/nvie/gitflow/wiki/Installation
  25. 76.

    add a new feature: > git flow feature start my_new_feature

    when done with the new feature: > git flow feature finish my_new_feature
  26. 77.

    Exercise: your boss ask you to add a new feature

    which can let user upload their photos, please try to finish this assignment in git flow.
  27. 78.

    Exercise: your boss find a bug and ask you to

    fix it ASAP, please try to do this assignment in git flow.
  28. 79.
  29. 83.
  30. 91.
  31. 92.
  32. 94.
  33. 96.

    Exercise: 1. clone a project from Github 2. do some

    changes 3. commit and push back to Github
  34. 97.

    Exercise: 1. create a new local branch 2. add some

    change and then push this branch to Github
  35. 99.

    push a tag: > git push origin v2.0 push several

    tags: > git push origin --tags
  36. 101.
  37. 102.
  38. 104.

    Exercise: 1. fork a project from your classmate who is

    sitting just next to you. 2. add some change and commit. 3. fire a pull request.
  39. 111.

    Exercise: 1. create a github page for your account. 2.

    set your domain name in CNAME if you have one.
  40. 115.

    Vim

  41. 125.
  42. 126.

    if you want to use my .vimrc 1. clone from

    my Github repo 2. cd to cloned repo and execute install script 3. make symbolic link for vim 4. done!
  43. 129.

    Modes Switch: 1. in normal mode, "i" or "a" or

    "o" to enter insert mode(i = insert, a = append, o = newline) 2. in insert mode, ESC or Ctrl+[ to enter normal mode 3. in normal mode, hit "v" or "V" to enter visual mode 4. in visual mode, hit ESC or Ctrl+[ to normal mode
  44. 131.
  45. 133.
  46. 134.

    - :w write to file. - :q exit Vim. -

    :tabe create a new tab. - gt to switch to next tab, gT to previous tab. (I map gt and gT to F7 and F8 in my vimrc) - :new to create a horizontal split window, :vnew or :vs to create a vertical split window.
  47. 135.

    - vi -o a.rb b.rb to open those two files

    at the same time with horizontal split window. - vi -O a.rb b.rb same as above, but in vertical split window. - vi -p a.rb b.rb to open files with tabs. - vi http://www.eddie.com.tw will read the source content into vim directly.
  48. 136.
  49. 138.

    - w or W to move cursor forward by a

    word, and b or B is backward. - 0 to back to the begin of the line, and $ is jump to the end. - fx will stop the cursor at the next "x" character in current line, and F is search backward.
  50. 139.

    - } will move cursor to next section, { move

    to last section. - vit will visually select content between the tag, while vat will even including the tag. - vi" will visually select content between current double quotes. - viw will select the current word.
  51. 140.

    - gg will move the cursor to the top of

    the current file, and G will jump to bottom. - zz, zb, zt - / search, n can jump to next matched result, and N will jump to last one. - * search the word on cursor.
  52. 144.
  53. 145.

    - D to clear all content of current line after

    the cursor. - C like D, but enter insert mode. - dG will clear all content after the cursor, dgg will clear all content before the cursor. - x remove a character. - . to repeat last action. - dd to delete whole line. - 3dd to delete 3 lines.
  54. 146.

    - yy yank the whole line of the cursor. -

    3yy yank 3 lines. - p paste content from register. - 4p paster content from register for 4 times. - = re-format - gg=G re-format whole file.
  55. 147.

    - dw, diw to delete the word in the cursor.

    - cw, ciw same as above, but enter insert mode. - r to replace current character. - J to concatenate current line with next line, 3J will concatenate next 3 lines. - > to add indentation, < to remove indentation.
  56. 148.
  57. 160.
  58. 163.
  59. 164.

    in terminal: 1. ctrl + z to stash vim, and

    type "fg" to bring it back. 2. ctrl + w to delete a word, ctrl + u to delete a whole line, both work in terminal and vim edit mode. 3. ctrl + r to find history commands fuzzily.