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 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
Git-ing Started • Windows msysGit: http://msysgit.github.com/ Git-Extensions: https://code.google.com/p/gitextensions/ • OS X o git-osx-installer:http://sourceforge.net/projects/git-osx-installer/ o via MacPorts
Git-ing Started • Linux Debian/Ubuntu: sudo apt-get install git RedHat/Fedora: yum install git-core • Compile from source
Lifecycle 1. clone / init 2. add / modify 3. commit 4. push 5. Repeat 2-4
New Unmodified Modified Staged Remoted Clone Add Lifecycle
New Unmodified Modified Staged Remoted Clone Add Edit Lifecycle
New Unmodified Modified Staged Remoted Clone Add Edit Stage Lifecycle
New Unmodified Modified Staged Remoted Clone Add Edit Stage Commit Lifecycle
New Unmodified Modified Staged Remoted Clone Add Edit Stage Commit Push Lifecycle
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) o git:// url.to/git/repo.git (port 9418) o ssh: username@host/path/to/git.repo o http(s):// url.to/git/repo • Pros & Cons for each o 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 o Newly stashed items are placed at the top of the stash stack: git stash save o Stashes are popped off the stack: git stash pop o 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
Recommend
More recommend