Introduction to git

1,084 views

Published on

Лекция посвящена основным принципам работа систем контроля версий и самой популярной на момент публикации такой системе - git.

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

  • Be the first to like this

No Downloads
Views
Total views
1,084
On SlideShare
0
From Embeds
0
Number of Embeds
535
Actions
Shares
0
Downloads
12
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Introduction to git

  1. 1. Code management problems and VCS review. Introduction to git. Aleksey Asiutin
  2. 2. Old good version control system
  3. 3. Working on the website index.htm
  4. 4. Collaboration index. html
  5. 5. “Our team” HTML page
  6. 6. Austin Powers came into the play
  7. 7. File changes
  8. 8. Add James Bond
  9. 9. File changes
  10. 10. Dr. Evil is bad
  11. 11. Dr. Evil is good
  12. 12. Merge problem
  13. 13. File changes history
  14. 14. File changes history
  15. 15. VCS Features ● Backup and Recovery ● Team Collaboration and Synchronization ● History Log ● Nonlinear Project Flow ● Find a Guy to Blame :)
  16. 16. VCS CVS Subversion mercurial git Source Safe
  17. 17. Centralized VCS
  18. 18. Distributed VCS
  19. 19. Classic VCS working scheme
  20. 20. How git works with files
  21. 21. git install http://git-scm.com/downloads
  22. 22. git configuration Current repository configs git action [arguments] Current user global configs git config --global user.name aasiutin git config --global user.email sutok85@gmail.com view all git configuration variables git config --list
  23. 23. git commands structure general command structure git action [arguments] getting help git help git help <action>
  24. 24. Initialize git repository git init Initialized empty Git repository in /Users/spu/mygithub/.git/
  25. 25. Clone remote git repository git clone https://github.com/aasiutin/twitter- api-php.git cloning into 'twitter-api-php'... remote: Counting objects: 24, done. remote: Compressing objects: 100% (16/16), done. remote: Total 24 (delta 3), reused 21 (delta 2) Unpacking objects: 100% (24/24), done.
  26. 26. File status Lifecycle
  27. 27. Check git status git status # On branch master nothing to commit (working directory clean)
  28. 28. Add README, check git status git status # On branch master # Untracked files: # (use "git add <file>..." to include in what will be committed) # # README nothing added to commit but untracked files present (use "git add" to track)
  29. 29. Start tracking files git add README $ git status # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # new file: README
  30. 30. git add use cases git add file1 file2 [file3 ...] #add list of files git add *.txt #add all txt files in current directory git add docs/*.txt #add all txt files in docs directory git add docs/ #add all files in docs directory git add "*.txt" #add all txt files in the whole project git add --all #add all files
  31. 31. modify tracked files $ git status # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # new file: README # # Changed but not updated: # (use "git add <file>..." to update what will be committed) # # modified: README
  32. 32. Commit changes to git $ git commit # Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # modified: README ~ ~ ~ ".git/COMMIT_EDITMSG" 10L, 283C $ git config --global core.editor [editor] $ git commit -a -m “Commit message goes here”
  33. 33. Commit changes to git (2) $ git commit -m "Message goes here" [master]: created 463dc4f: "Message goes here" 2 files changed, 3 insertions(+), 0 deletions(- ) create mode 100644 README
  34. 34. Deleting and moving files $ git rm [filename] rm “[filename]” $ git rm -f [filename] #remove changed file $ git rm --cached [filename] #remove only from git, but not from filesystem $ git mv old-name new-name #rename/move file $ mv old-name new-name $ git rm oldname $ git add new-name
  35. 35. Undo changes $ git commit --amend #modify last commit $ git reset HEAD [filename] #unstage file, keep changes $ git checkout HEAD -- [filename] #discard all file changes and return last commit file state
  36. 36. Ignoring files $ cat .gitignore # a comment - this is ignored *.a # no .a files !lib.a # but do track lib.a, even though # you're ignoring .a files above /TODO # only ignore the root TODO file, not # subdir/TODO build/ # ignore all files in the build/ # directory doc/*.txt # ignore doc/notes.txt, but not # doc/server/arch.txt
  37. 37. View changes and commit history $ git diff #view unstaged changes $ git diff --staged #view staged changes $ git log #view commit history -p --stat --graph --pretty=oneline|short|full|fuller|format --since --untill --before --after $ git log --pretty=format:”%h - %an” --before=”2 days ago” --after=”2013-04-25”

×