A Crash Course on Git Sean Payne Temecula Valley Software - - PowerPoint PPT Presentation
A Crash Course on Git Sean Payne Temecula Valley Software - - PowerPoint PPT Presentation
A Crash Course on Git Sean Payne Temecula Valley Software Developers Meetup What is Git? Distributed Version Control System (DVCS) Built from 2005 onwards by the Linux kernel dev team Like CVS, SVN & others, allows historical
What is Git?
- Distributed Version Control System (DVCS)
- Built from 2005 onwards by the Linux kernel
dev team
- Like CVS, SVN & others, allows historical
tracking of changes
- Unlike CVS, SVN & others, it is
decentralized
Why choose Git?
- Open source
- Lightweight & fast
- Entire history is local
- Powerful & easy branching & merging
- Stashing
- Rapidly growing / enthusiastic community
- Decentralized
- Free
- Windows
msysGit: http://msysgit.github.com/ Git-Extensions: https://code.google.com/p/gitextensions/
- OS X
- git-osx-installer:http://sourceforge.net/projects/git-osx-installer/
- via MacPorts
Git-ing Started
- Linux
Debian/Ubuntu: sudo apt-get install git RedHat/Fedora: yum install git-core
- Compile from source
Git-ing Started
Lifecycle
- 1. clone / init
- 2. add / modify
- 3. commit
- 4. push
- 5. Repeat 2-4
Lifecycle
New Unmodified Modified Staged Remoted Add Clone
Lifecycle
New Unmodified Modified Staged Remoted Add Clone Edit
Lifecycle
New Unmodified Modified Staged Remoted Add Clone Edit Stage
Lifecycle
New Unmodified Modified Staged Remoted Add Clone Edit Stage Commit
Lifecycle
New Unmodified Modified Staged Remoted Add Clone Edit Stage Commit Push
git init .
git config user.name
git add .
git commit -m “Initial commit”
Branching
- Allows concurrent
modifications from a given point
- ‘master’ is the
default mainline branch
- Branches are
merged
git branch test && git checkout test
Modifying in branch
Switching branches
Merging
Moving in on your turf
Would you like to play a game?
Fighting with yourself
So similar, but different
Two become one
Resolving conflicts
Resolving conflicts
Give & Take (Pushing & Pulling)
- Can be local folder
- Or remote host (e.g. GitHub, BitBucket)
- git://url.to/git/repo.git (port 9418)
- ssh:username@host/path/to/git.repo
- http(s)://url.to/git/repo
- Pros & Cons for each
- See the following for more info:
http://git-scm.com/book/en/Git-on-the-Server-The-Protocols
Sweep it under the rug (Stashing)
- Commits current changes to a special
branch and restores last committed state.
- Stashes are stored as a stack
- Newly stashed items are placed at the top of the
stash stack: git stash save
- Stashes are popped off the stack: git stash pop
- Stash stack items can also be “out-of-stack” if
necessary: git stash pop <stash id>
But wait, there’s more!
- Tags
- Rebasing
- Cherry Picking
- SVN interop*
- Bisect
- Submodules
Additional Information
- https://git.wiki.kernel.org/index.php/Main_Page
- http://git-scm.com/
- http://help.github.com
- http://www.launchacademy.com/codecabulary/learn-git/
Thanks!
Sean Payne www.seanpayne.name