Practical Git

3,272 views

Published on

Slides from the talk I did on git at the May laphp meetup.

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

No Downloads
Views
Total views
3,272
On SlideShare
0
From Embeds
0
Number of Embeds
62
Actions
Shares
0
Downloads
106
Comments
0
Likes
5
Embeds 0
No embeds

No notes for slide


























  • Practical Git

    1. 1. Practical Git Fun things we do with git
    2. 2. About Me/ Matt Weghorst, @mattweg COO by day, Dev by night ESN Interactive - Hollywood, CA Lead Generation Marketing Small teams develop on a PHP5/CakePHP platform 6 main applications, run 20+ sites, full API, deliver via clients’ APIs
    3. 3. Distributed Revision Control CVS, SVN, and Git are the most popular (many others too) Common Concepts Repositories - Local and Remote Branching/Merging/ Tagging
    4. 4. Why git? Great external collaboration sites GitHub.com, TheChaw.com, etc Really easy remote setup No .svn directories Great features, good documentation (http://git-scm.com/) STABLE!
    5. 5. Installing git OSX git-osx-installer - http://code.google.com/p/git-osx- installer/ mac ports - http://macports.org/ (search for git-core) make, make install - http://git-scm.com/download PC http://www.cygwin.com/ (Linux emulator) http://code.google.com/p/msysgit/ *nix http://git-scm.com/download
    6. 6. Git it (the basics)
    7. 7. Git it (the basics) Official git tutorial - http://git-scm.com/documentation
    8. 8. Git it (the basics) Official git tutorial - http://git-scm.com/documentation `git init`- start a clean repo and creates the .git directory in the project
    9. 9. Git it (the basics) Official git tutorial - http://git-scm.com/documentation `git init`- start a clean repo and creates the .git directory in the project `git clone [remote address]`- creates a local repo from an existing remote repo
    10. 10. Git it (the basics) Official git tutorial - http://git-scm.com/documentation `git init`- start a clean repo and creates the .git directory in the project `git clone [remote address]`- creates a local repo from an existing remote repo `git status` - get used to typing this one (current status of the repo)
    11. 11. Git it (the basics) Official git tutorial - http://git-scm.com/documentation `git init`- start a clean repo and creates the .git directory in the project `git clone [remote address]`- creates a local repo from an existing remote repo `git status` - get used to typing this one (current status of the repo) `git diff [path/to/file.ext]` - shows un-committed changes to the selected file
    12. 12. Git it (the basics) Official git tutorial - http://git-scm.com/documentation `git init`- start a clean repo and creates the .git directory in the project `git clone [remote address]`- creates a local repo from an existing remote repo `git status` - get used to typing this one (current status of the repo) `git diff [path/to/file.ext]` - shows un-committed changes to the selected file `git add [path/to/file.ext]` - adds the file to be included in the next commit
    13. 13. Git it (the basics) Official git tutorial - http://git-scm.com/documentation `git init`- start a clean repo and creates the .git directory in the project `git clone [remote address]`- creates a local repo from an existing remote repo `git status` - get used to typing this one (current status of the repo) `git diff [path/to/file.ext]` - shows un-committed changes to the selected file `git add [path/to/file.ext]` - adds the file to be included in the next commit `git commit -m “[non-lame commit message]”` - creates the commit with the included message
    14. 14. Going remote share some code already
    15. 15. Going remote share some code already Easy option - http://GitHub.com public = free, private = cheap just configure your .ssh key and you can start cloning or creating projects
    16. 16. Going remote share some code already Easy option - http://GitHub.com public = free, private = cheap just configure your .ssh key and you can start cloning or creating projects Custom options (still much easier than svn remote) `ssh [remote.server.com]`- log in to your server (.ssh key is best) `mkdir [path/for/remote.git]`- wherever you want to store it `cd [path/for/remote.git]` `git --bare init` - empty repo is ready to be cloned `git clone [ssh://remote.server.com/path/for/remote.git]` - add files from local and push
    17. 17. Going rouge (branching)
    18. 18. Going rouge (branching) Branch - variations of the code base inside a single repository
    19. 19. Going rouge (branching) Branch - variations of the code base inside a single repository `git checkout master` - default branch
    20. 20. Going rouge (branching) Branch - variations of the code base inside a single repository `git checkout master` - default branch `git branch [newbranch]` - create a new branch based on the HEAD revision of the current branch
    21. 21. Going rouge (branching) Branch - variations of the code base inside a single repository `git checkout master` - default branch `git branch [newbranch]` - create a new branch based on the HEAD revision of the current branch `git checkout [newbranch]` - keep things separate until you decide to...
    22. 22. Going rouge (branching) Branch - variations of the code base inside a single repository `git checkout master` - default branch `git branch [newbranch]` - create a new branch based on the HEAD revision of the current branch `git checkout [newbranch]` - keep things separate until you decide to... `git merge [frombranch]` - takes all of the changes from the specified branch and merges into the current branch
    23. 23. Who broke that? viewing history
    24. 24. Who broke that? viewing history `git log` - shows commit history very powerful, read the docs and you’ll figure out how to find what you are looking for
    25. 25. Who broke that? viewing history `git log` - shows commit history very powerful, read the docs and you’ll figure out how to find what you are looking for `git show [commit]`- see what changed in the specific commit
    26. 26. Who broke that? viewing history `git log` - shows commit history very powerful, read the docs and you’ll figure out how to find what you are looking for `git show [commit]`- see what changed in the specific commit `git blame [path/to/file.ext]` - see who and which commit is responsible for each line of a file
    27. 27. Who broke that? viewing history `git log` - shows commit history very powerful, read the docs and you’ll figure out how to find what you are looking for `git show [commit]`- see what changed in the specific commit `git blame [path/to/file.ext]` - see who and which commit is responsible for each line of a file `git bisect` - totally awesome - helps you figure out exactly which commit created a bug
    28. 28. How we use git and we’re pretty awesome Everybody uses it - even designers Staging server holds all of our remote repositories post-commit hook automatically pushes commits to the staging server for testing after testing, the `golive` shell script lets you review changes since last publish and sends to our production servers
    29. 29. Check me out some awesome commands `git log live..master --no-merges --pretty=format:'%h by %an, %ar, message: %s'` `git show [rev#] --stat` `git diff live..master --stat` `git cherry-pick -x [rev#]`

    ×