An Introduction to Git
MitMaro
Feel free to interrupt me at any point to ask questions. I will try my best.
Prerequisites
Some basic understanding of the Bash command line interface
A basic understanding of version control
I will also be making comparisons where I can to Subversion as it is the only other version control system that I feel comfortable with.
I may also make a few comparisons to CVS; but not as often
If you are not familiar with bash or version control in general you should still be fine.
Overview
What is Git?
Benefits of Git
Creating a Repository
What is Git?
Developed by Linus Tolvalds - the creator of the Linux Kernel
Written with performance in mind
Virtually impossible for repository to become corrupted without noticing
Written in April of 2006
Linux kernel developers decided to stop using Bitkeeper; their previous version control system
Note: Corrupted without you immediately being aware.
What is Git?
A Distributed Version Control System
No dependency on a centralized server
Every copy of the repository can be a server
Vastly different than Subversion or CVS
Git is similar to Mercurial and Bitkeeper
Benefits of Git
Distributed Nature
Performance
Easy Setup
Locally stored repository allows continued interaction with the repository even without a network communication
I have used Git while flying; something nearly impossible with Subversion or CVS.
Benefits of Git - Distributed Nature
Locally stored repository
No network connection required
Locally stored repository allows continued interaction with the repository even without a network communication
I have used Git while flying; something nearly impossible with Subversion or CVS.
Benefits of Git - Performance
Written to be fast
No network connection required for most operations
Network latency can slow things down dramatically
Benefits of Git - Easy Repositories
Creating repositories is very simple
You will use Git repositories for everything
You will see in a few minute how simple it is
No special setup
One off scripts, research papers, presentations.
Benefits of Git - Others
Easy branching
Easy merging with merge tracking
I won't be going into detail on these, but they exist.
Drawbacks of Git
Can have a difficult learning curve
Lack of tools in Windows
No sub-tree checkouts
Submodules can be painful
Can't commit empty directories
I won't be going into to much detail of the drawbacks of Git.
But there are some
Why are you using Windows?
Tools are getting better in windows
Learning: This was more of a problem when Git first came out; not so much now because of great resources available
People familiar with Subversion or CVS may find things more difficult because many things in Git are difficult to relate
You can't checkout a part of the code base, it's all or nothing
Submodules are like svn:externals
There are ways to work around empty directories
Git Status
From here on I will be doing a more interactive presentation.
Git Remotes
Working alone is lonely
Git Remotes make things less lonely
Git Remotes allow for the synchronizing of changes
So far we have worked with a local repository and one sole committer.
In practice there are usually several committers to a project
This is where git remotes come in to play by allowing the push and pull of changes
Git Remotes - GitHub
GitHub is just a service; it's not Git
Allows for easier collaborative work
Provides a centralized place for you repository
There are other services like GitHub
GitHub will be our remote repository
Git Workflows
Centralized Model
Fully Distributed Model
Decentralized Model
Hybrid Centralized Model
Workflows for 2 or more people. Not for individuals.
This is only a introduction to the workflows.
I won't explain how to use them.
Git Workflows - Centralized Model
Very familiar to anyone who used a centralized version control system
Everyone pushes and pulls to a centralized copy of the repository
This copy is considered the canonical copy of the repository
Works well when there needs to be one authoritative copy of the repository
Extremely structured workflow
This is common in industry; at least from my experience
But you also loose out on many benefits of Git
Too structured in my opinion
Git Workflows - Fully Distributed Model
Developers push and pull to one another
No clear canonical copy of the repository exists
Extremely unstructured development
Often used in small projects
Not ideal for larger more mature projects
Used in small projects where developers are experimenting with new ideas and want to share them.
Git Workflows - Decentralized Model
There is one canonical copy of the repository
Network of trust
All developers push to a set of trusted "Generals"
"Generals" push to the central repository
Used in projects with a large amount of developers
Can work in smaller settings
Used by the Linux Kernel team
Git Workflows - Centralized Hybrid Model
Minor modification to the centralized model
Developers are allowed to push/pull to each other
Developers push finalized code to a central repository
A gate keeper can sit in front of the central repository
Fits well in industry
Central repository remains stable
If you are interested in learning more about Git workflows I am hoping to do another presentation.
The End
Thank You!