Living with Files More Happily

529 views

Published on

This is for a research group meeting on May 7, 2014.

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

  • Be the first to like this

No Downloads
Views
Total views
529
On SlideShare
0
From Embeds
0
Number of Embeds
6
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Living with Files More Happily

  1. 1. LIVING WITH FILES MORE HAPPILY Yusuke Endo
  2. 2. VERSION CONTROL
  3. 3. WHAT WE DO • Create files • Edit files • Save files • Delete files Files the result ONLY
  4. 4. WHAT ISVERSION CONTROL? Files with their HISTORY
  5. 5. PRIMITIVE WAY awesome_euler.c awesome_runge_kutta.c blah_blah_v1.tex blah_blah_v2.tex Error-prone • Repetition • What does v1 do? • Vulnerable to unintentional changes/deletions
  6. 6. WHAT WE WANT • Record who changes files what/when/why changes were made • Review changes • Restore files to a past state
  7. 7. Git Logo by Jason Long
  8. 8. WHAT IS GIT? • a version control system(VCS) • developed in 2005 by LinusTorvalds • used for Linux Kernel, Ruby On Rails, etc.
  9. 9. WHY GIT? git is • Growing in share • Simple (compared to otherVCSs) • Distributed • Fast
  10. 10. Git Logo by Jason Long BASIC CONCEPTS
  11. 11. REPOSITORY WORKINGTREE Repository Files file Project Directory Meta Data commits, etc.
  12. 12. COMMIT Files Commit 145ab3e5… snapshot file
  13. 13. REPOSITORY 145ab3e5… 3eab3e51… a4661aca… … HEAD
  14. 14. TAG 145ab3e5… 3eab3e51… a4661aca… … v0.9.1
  15. 15. CHECKOUT WORKTREE Repository Files file Project Directory checkout
  16. 16. STAGE / INDEX Changed Files file Staged Files Commit 145ab3e5… stage
  17. 17. SUMMARY WorkingTree Staged Files Repository checkout stage commit Changed Files edit
  18. 18. Git Logo by Jason Long BASIC COMMANDS
  19. 19. BASIC COMMANDS Initialize a repository $ git init Stage files $ git add <file> Commit $ git commit [-m “message”] Help $ git help
  20. 20. BASIC WORK FLOW 1. Edit Files 2. $ git add <file> $ git commit -m “message”
  21. 21. BEST PRACTICE Commit Commit Message 1 | a short summary of the change 2 | 3 | if needed 4 | why you made the change 5 | … • should be small • should not consist of changes which can be logically separable
  22. 22. OTHER USEFUL COMMAND Show commit logs $ git log Show the working tree status $ git status Show difference between the latest commit and the working tree $ git diff HEAD
  23. 23. DEMO
  24. 24. Git Logo by Jason Long BRANCH
  25. 25. BRANCH 145ab3e5… 3eab3e51… a4661aca… … … … testing master
  26. 26. MERGE 145ab3e5… 3eab3e51… a4661aca… … testing master merge
  27. 27. CONFLICT 145ab3e5… 3eab3e51… … changes a.tex changes a.tex conflictmerge
  28. 28. REBASE 145ab3e5… 3eab3e51… master rebase … testing
  29. 29. Git Logo by Jason Long BRANCH COMMANDS
  30. 30. COMMANDS Show branches $ git branch Create a branch $ git branch <branch> Checkout a branch $ git checkout <branch> Merge <branch> to the current branch $ git merge <branch> Rebase <branch> to the current branch $ git rebase <branch>
  31. 31. DEMO
  32. 32. Git Logo by Jason Long REMOTE
  33. 33. MERIT • Backup • Easily Collaborate with others
  34. 34. DISTRIBUTED CentralizedVCS DistributedVCS Working Tree Working Tree Repo Repo Repo commit checkout push pull commit checkout remote local
  35. 35. WHERETO CREATE Github Bitbucket Public Repository … free Public / Private Repository … free up to 5 users https://github.com/ https://bitbucket.org/ https://education.github.com/ • A git server you have • Storage services like Dropbox • Hosting Services
  36. 36. CLONE Remote Repository clone Repository Working Tree checkout remote local
  37. 37. PUSH push A B A B C Cremote local
  38. 38. PULL pull A B A B C Cremote local
  39. 39. Git Logo by Jason Long REMOTE COMMANDS
  40. 40. COMMANDS Create a repository without working tree $ git --bare init Clone $ git clone <repository> Push $ git push <remote> <branch> Pull $ git pull <remote> <branch>
  41. 41. DEMO
  42. 42. ADDITIONAL INFORMATION
  43. 43. INSTALLATION Linux $ yum install git-core $ apt-get install git Mac $ brew install git Windows http://msysgit.github.com/ Git may be already installed. To update by homebrew
  44. 44. INITIAL CONFIGURATION git config --global user.name “Your Name" git config --global user.email “mail@example.com“ ! git config --global color.diff auto git config --global color.status auto git config --global color.branch auto git config --global color.grep auto ! git config --global core.excludesfile $HOME/.gitignore git config --global push.default current
  45. 45. GIT CLIENT CUI GUI • tig • GitHub for <platform> • SourceTree • etc.
  46. 46. FURTHER READING Pro Git http://git-scm.com/book/ Git from the bottom up http://ftp.newartisans.com/ pub/git.from.bottom.up.pdf
  47. 47. THANKYOU!

×