Your SlideShare is downloading. ×
0
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Git Magic: Versioning Files like a Boss
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Git Magic: Versioning Files like a Boss

1,917

Published on

Video available at: http://cs50.tv/2011/fall/seminars/Git_magic/Git_magic.mp4

Video available at: http://cs50.tv/2011/fall/seminars/Git_magic/Git_magic.mp4

Published in: Education, Technology
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,917
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
28
Comments
0
Likes
3
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • mkdir repo\nvim index.php: <?php echo ‘git rocks’; ?>\nvim page.php: <?php echo ‘tommy does, too’; ?>\ngit init\n
  • \n
  • git status\n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • git add --all\ngit commit\n
  • \n
  • \n
  • vim page2.php: <?php echo ‘woo more commits’; ?>\nvim index.php: <?php echo ‘I made a change!’; ?>\ngit add --all\ngit commit -m “another commit”\ngit log\n
  • \n
  • git show\ngit show PREVIOUS COMMIT\n
  • \n
  • \n
  • \n
  • \n
  • \n
  • git branch test\ngit branch\ngit checkout test\ngit branch\nvim crazy.php: <?php echo ‘this is a crazy idea’; ?>\ngit add --all\ngit commit -m “so crazy up in here”\nls\ngit log\ngit checkout master\nls\ngit log\n
  • \n
  • \n
  • git branch\ngit checkout master\nvim index.php: <?php echo ‘this page is boring’; ?>\ngit add --all\ngit commit -m “third commit on master”\ngit merge test\ngit log\n
  • git branch -D test\ngit branch\n
  • \n
  • \n
  • git log --graph\ncd ../rebased\ngit checkout master\ngit rebase test\ngit log --graph\ncd ../repo\n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • ls\ngit log\nvim index.php: <?php echo ‘good idea’; ?>\ngit commit -a -m “sweet”\nvim index.php: <?php echo ‘bad idea’; ?>\ngit commit -a -m “oops”\ngit revert to commit “sweet”\nCONFLICT!\ngit status\nvim index.php\ngit commit -a -m “revert”\ngit log\n
  • vim index.php: <?php echo ‘only gonna add this’; ?>\ngit add --all\ngit checkout -- index.php\nvim index.php\ngit checkout <commit with “sweet”> index.php\nvim index.php\n
  • git reset --hard HEAD\n
  • git checkout <commit with “another commit”>\ngit log\ngit reflog\ngit checkout master\n
  • git bisect good <first commit>\ngit bisect bad HEAD\ngit bisect bad\ngit checkout master\n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • git remote add origin git@github.com:tmac721/seminar.git\ngit remote\ngit remote show origin\ngit push origin master\n
  • cd ../\ngit clone git@github.com:tmac721/seminar.git\ncd test\nls\ngit log\n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • ssh cloud\nmkdir repo\ncd repo\ngit init --bare\ncd hooks\nvim post-receive: copy this\nchmod a+x post-receive\ngit remote add origin ssh://tmacwill@cloud.cs50.net/home/tmacwill/repo\ngit push origin master\n\n
  • \n
  • \n
  • \n
  • \n
  • Transcript

    1. Git Magic:Versioning Files Like a Boss Tommy MacWilliam tmacwilliam@cs50.net
    2. Today• setting up like a boss• basic git like a boss• using branches like a boss• reverting changes like a boss• collaborating like a boss
    3. Git is...• “Git is distributed version control system focused on speed, effectivity and real-world usability on large projects” • “distributed development” • “non-linear development” • “efficient handling of large projects” • “cryptographic authentication of history”
    4. Git is...
    5. Git is...Awesome.
    6. Installing Git• Windows: http://code.google.com/p/ msysgit/• OS X: http://code.google.com/p/git-osx- installer/• Appliance: already installed!
    7. Installing Gitroot@appliance(~): gitusage: git [--version] [--exec-path[=<path>]] [--html-path] [-p|--paginate|--no-pager] [--no-replace-objects] [--bare] [--git-dir=<path>] [--work-tree=<path>] [-c name=value] [--help] <command> [<args>]
    8. git config --globaluser.name“Tommy MacWilliam”
    9. git config --globaluser.emailtmacwilliam@cs50.net
    10. git init
    11. Commits• snapshots of your project• what your files look like at a given point• single event in project history
    12. git status
    13. git add index.php
    14. git add --all
    15. git add --all
    16. git add --allgit commit
    17. Commit Messages• short message describing what’s different in this commit• add any new features?• fix some bugs?• break anything?
    18. Commit Messages
    19. Commit Messages• http://www.commitlogsfromlastnight.com/
    20. git commit -a -m “oh hi, mark!”
    21. git log
    22. 5aeebab117b892fa42002146e4c62be676bc4621b43b0ad1e8108e7ab870d7a54feac93ae8b8600e461476587780aa9fa5611ea6dc3912c146a91760
    23. Commit 5aeebab117b892fa42002146e4c62be676bc4621 ID b43b0ad1e8108e7ab870d7a54feac93ae8b8600e 461476587780aa9fa5611ea6dc3912c146a91760HEAD
    24. git show
    25. git show b43b0
    26. git initgit status git addgit commit git log git show
    27. git initgit status git addgit commit git log git show
    28. Branches• non-linear development process • changes on one branch do not affect other branches• crazy idea? make a branch• didn’t work? delete the branch• all done? merge the branch
    29. git branch test
    30. git branch test
    31. git branch testgit checkout test
    32. 5aeeb b43b0 46147master
    33. 5aeeb git branch test b43b0 f862f 46147 36223master test
    34. git merge
    35. 5aeeb b43b0 f862f 46147 36223 git merge 87aedmaster test
    36. Like a boss.
    37. git branch -D test
    38. Merge vs. Rebase• git merge: new commit, non-linear history• git rebase: no new commit, linear history
    39. 5aeeb git branch test b43b0 f862f 46147 36223master test
    40. 5aeeb b43b0 git rebase 46147 f862f 36223master
    41. Conflicts• change in one branch can be incompatible with another• git tries to resolve, but sometimes cannot
    42. Conflict Resolutionint main(int argc, char** argv) { printf(“you invited all my friends”);}int main(int argc, char** argv) { printf(“good thinking!”);}
    43. Conflict Resolutionint main(int argc, char** argv) { <<<<<<< HEAD:file.c printf(“you invited all my friends”); ======= printf(“good thinking!”); >>>>>>> f862f:file.c}
    44. git checkout git branch git merge git rebase
    45. git checkout git branch git merge git rebase
    46. git commit -m “oops.”
    47. git revert b43b0
    48. 5aeebb43b046147
    49. 5aeebb43b046147 git revert b43b0 42bb4(b43b0)
    50. File-Specific Reverts• git checkout -- index.php • replace with version in index• git checkout b43b0 index.php • replace with version in commit b43b0
    51. git reset --hard b43b0
    52. git reflog
    53. git bisect
    54. Like a boss.
    55. git revert git resetgit checkout git bisect
    56. git revert git resetgit checkout git bisect
    57. “distributed development”
    58. ssh-keygen
    59. git pushgit@github.com:cs50/project master
    60. git remote add origingit@github.com:cs50/project
    61. git remote add origingit@github.com:cs50/projectgit push origin master
    62. git clonegit@github.com:cs50/project
    63. git pull origin master
    64. git pull --rebase
    65. git initgit add --allgit commit Alice Bob
    66. git remote add origin urlgit push origin master Alice Bob
    67. git remote add origin urlgit push origin master Alice Bob
    68. git clone urlAlice Bob
    69. git clone urlAlice Bob
    70. git add --all git commitAlice Bob
    71. git push origin masterAlice Bob
    72. git push origin masterAlice Bob
    73. git pull origin masterAlice Bob
    74. git pull origin masterAlice Bob
    75. git branch -a
    76. git checkout -b origin/test
    77. scp ~/.ssh/id_rsa.pubhost:~/.ssh/authorized_keys
    78. git init --bare
    79. git remote add liveuser@cloud.cs50.net:~/project
    80. git remote add liveuser@cloud.cs50.net:~/project git push live master
    81. Hooks• applypatch-msg • post-applypatch• commit-msg • pre-commit• post-commit • pre-commit-msg• post-receive • pre-rebase• post-update • update
    82. post-receive#!/bin/shGIT_WORK_TREE=/home/tmacwill/public_html git checkout -fchmod -R 644 /home/tmacwill/public_html/*.htmlchmod -R 600 /home/tmacwill/public_html/*.php
    83. Like a boss.
    84. git clonegit pushgit remote git pull
    85. git clonegit pushgit remote git pull
    86. More Resources• http://progit.org/book/• http://book.git-scm.com/• http://gitref.org/• http://git-scm.com/documentation
    87. git commit -a -m “thanks!”

    ×