Slides from my talk at ALT.NET Cork.
Unlike centralized version control systems, the distributed nature of Git allows you to be far more flexible in how developers collaborate on projects.In this session I'll take you through a quick tour of the essential git commands with some demos.We'll cover branching and merging strategies, pull requests ,working on open source (GitHub etc), git clients and git deployments to the cloud.
2. What is Git?
Distributed version control system
Open source ,written in C
Linus Torvalds 2005 to maintain the linux kernel
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
Centralised
Distributed
History only on the server
Complete history of the repo locally
Commit changes online only
Nearly every operation is local (offline) you can
commit locally & branch locally
Down tools if server is down
No hassle if server is down, redundant by default
Branching is difficult
Branching is really easy & lightweight
Branching is no longer a dirty word
Everyone commits to main repo ,typically you check More flexible workflows, you commit changes more
in when your work is complete
regularly
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 …
15. .gitignore file
Tells git to ignore specific files / folders
https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
16. Branching
• Think of a branch as simply a movable pointer to one of the commits in your
repository
• $git branch < new branchname >
• $git checkout <branchname>
• $git merge <branchname>
20. Git-Flow
•Vincent Driessen's branching model
•Defines a branching model designed around the project release, suitable for managing larger
projects / large teams
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
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
Shells
SourceTree (free)
Bash
GitHub for Windows
Posh-git
Git GUI for Windows
Powershell
TortoiseGit
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