1 / 31

Essential Git For Developers

Essential Git For Developers. Cork ALT.NET December 2013. What is Git?. D istributed version control system Open source ,written in C Linus Torvalds 2005 to maintain the linux k ernel. Why Git?. F ocuses on content not files Opt in when it comes to commits

belita
Download Presentation

Essential Git For Developers

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Essential Git For Developers Cork ALT.NET December 2013

  2. What is Git? • Distributed version control system • Open source ,written in C • Linus Torvalds 2005 to maintain the linuxkernel

  3. Why Git? • Focuses on content not files • Opt in when it comes to commits • Open, not closed– open source model of working is baked into the software • Distributed - works almost entirely offline • It changes how you work – commit more often, making code reviews easier • Browsing history is lightening fast • Non-linear development

  4. Centralized vs. Distributed

  5. Demo – create a repo and add some files

  6. Commands • $git init • $git add <fileName> • $git commit –m <commit message> • $git status • $git log • $git command --help

  7. Staging Working Directory git add Staging Area git commit Repository

  8. File Status stackoverflow.com/questions/15653066/how-to-track-but-not-stage-and-how-to-unstage-but-not-untrack

  9. Git stores snapshots, not differences git-scm.com/book/en/Getting-Started-Git-Basics

  10. Demo – working with remotes

  11. Commands • $git remote add <name> <url> • $git push <remote name> <local branch name> • $git clone <path to repo>

  12. Git on the Server • Protocols –SSH , HTTP • HTTP - slower but allows anonymous access to the files • SSH - faster but everyone needs a unique SSH key • Hosting Options • Self Hosted (GitLab CE) • GitHub, BitBucket & many more …

  13. Demo – web hook integration

  14. $git pull command • $git fetch + $git merge = $git pull

  15. .gitignore file Tells git to ignore specific files / folders https://github.com/github/gitignore/blob/master/VisualStudio.gitignore

  16. Branching • $git branch < new branchname> • $git checkout <branchname> • $git merge <branchname> • Think of a branch as simply a movable pointer to one of the commits in your repository

  17. Fast forward merge Before merging After merge

  18. 3 way merge Before merging After merge

  19. Demo – branching and merging

  20. Git-Flow • Vincent Driessen's branching model • Defines a branching model designed around the project release, suitable for managing larger projects / large teams

  21. TIME

  22. Rebasing • “Take my commits and replay them after the HEAD of another branch.” • take all the changes that were committed on one branch and replay them on another one. • Moves a branch to a new base commit • Completely rewrites history! • Don’t do this on a shared branch

  23. MERGE RESULT REBASE RESULT

  24. Forking & Pull Requests

  25. Demo – exploring the repo history

  26. Debugging git blame $git blame [-L ine1,line2]] <file> • Lets you see when each line of a method was edited and by whom

  27. Debugging git bisect $ git bisect start $ git bisect bad HEAD $ git bisect good 1b6d

  28. Cherry Picking If you want to get one single commit out of a branch $git cherry-pick <sha-1_commit>

  29. Git on Windows • GUI Clients • SourceTree (free) • GitHub for Windows • Git GUI for Windows • TortoiseGit • Shells • Bash • Posh-git • Powershell • Cmd

  30. Advice for getting started • Learning curve • Start with the command line, not the GUI • Agree a good branch strategy with your team up front • (Almost) every should be short lived, and kept up to date with master • Commit often, perfect later & user meaningful commit messages

  31. Thanks for listening!twitter : @AIDANJCASEY

More Related