2. Revision Control Systems
● Automation of storing, retrieval, logging,
identification, and merging of revisions
● Current state + history of changes
● Mainly source code tracking - but also
binaries
● Usually has CLI, but we prefer GUI and IDE
integration for ease and clarity
3. Centralized vs Distributed
● Client-Server
● Central repository
● Store changes
locally
● Slow access to
non-local
● SVN, CVS
● Peer-to-peer
● Each user forks the
entire repository
● Fast performance
● “Actual” state
issues
● Git, Mercurial
4. Industry status - 2013
http://zeroturnaround.com/rebellabs/devprod-report-revisited-version-control-systems-in-2013/
6. SVN
● Apache Subversion
● Centralized version control system (CVCS)
● Created 2000 as CVS replacement, top-level
Apache - project 2010
● Widely used across the industry
● Mature system
● Good GUI tools
Wikipedia
7. Basic Concepts
● Repository - central server
● Trunk - current state
● Tag - named snapshot
● Branch - development fork
● Working copy - private workplace
● Commit - push local changes to server
● Update - update local with server changes
8. Model
● Current state at trunk
● Snapshots
● Copy to different branch when
changing direction (e.g. new
version)
● Backups and CI at repository
Source
9. Workflow
1. Checkout from trunk to working directory
2. Develop feature / fix bug
3. Update working directory
4. Merge conflicts
5. Commit changes to server
6. Go to 2
Note: one branch usually - costly merges!
10. Git
● Distributed version control system (DVCS)
● Created 2005 by Linus Torvalds for Linux
kernel development
● Embraced by FOSS - and by industry
● Independent of network state
● Fast due to locality
● Smaller sized directories
Wikipedia
11. Basic Concepts
● Local repository - local copy (fork)
● Staging area - files to be committed next
● Working directory - files changes made to
● Commit - copy changes from staging area to
local repository
● Branch - a separate line of development
● Clone - mirror an entire repository
12. Basic Concepts
● Tag - immutable name for a commit
● Pull - update local repo from remote repo
● Push - update remote repo with local repo
● HEAD - pointer to latest commit
● Revision - version of code, represented by
commits and identified by SHA1 hash
● URL - the repo’s location
13. Basic Concepts
● Stash - a “stack” style cache of changes
o used to save temp progress when changing branch
● master - main branch of the repository
● origin - pointer to origin of master, by
convention
● remote - pointer to remote repository
o usually - the upstream
15. Branching Model
● master
o hotfix
● [customer-name]
● [older version]
● release
● develop
o feature-xyz
o bugfix-tracking-number git-flow
16. “Squash” Workflow
1. Pull to update your local master
2. Check out a feature branch
3. Do work in your feature branch, committing
early and often
4. Rebase frequently to incorporate upstream
changes
5. Interactive rebase (squash) your commits
17. “Squash” Workflow
6. Merge your changes with master
7. Push your changes to the upstream
8. Delete unnecessary leftovers
http://reinh.com/blog/2009/03/02/a-git-workflow-
for-agile-teams.html
18. Deliverables
● master -> CI -> STABLE -> production
o “final”
● hotfix -> CI -> STABLE -> production
● release -> CI -> RC -> production/staging
o “beta”
● develop -> CI -> NIGHTLY -> staging
o “alpha”
● feature / fix / bugfix / local -> testing
19. Important
● Master + release [+ customer] - deployable!
● Branch per feature and per bug
● Branch often - commit and merge even more
● Remote - for tracking, local - for
experimenting
● Descriptive naming
20. Summary
Why Git?
● Industry choice
● No SPOF
● Branch often
● Faster and easier merges
● Agile-friendly model
● Clarity and workflow control
24. Basic Commands
● git --version
o version of locally installed git server
● git --bare init
o create local repository without working directory
o useful for “server” repository
● git init
o creates local repository with a working directory
25. Basic Commands
● git status -s
o show current status of staging area
● git add .
o add all changed files to staging area
● git add [filename]
o add specific file to changing area
● git commit -m ‘Message’
o commit files in staging area with message ‘Message’
26. Basic Commands
● git remote add [branch name] [URL]
o specify branch name at URL as our remote
o branch can be origin
● git push [branch-name1] [branch-name2]
o push changes from branch2 to branch1
o can be remote, origin, master, etc
● git clone [URL]
o clone URL to current directory as a local repository
27. Basic Commands
● git log
o show the commit log
● git show [SHA1]
o show details and diff of specific commit
● git commit --amend -m ‘Message’
o fix last commit
● git diff
o show the diff from last commit
28. Basic Commands
● git pull
o sync local repository with remote
● git stash
o save current changes before switching to a different
branch
o not a commit
● git stash list
o see current stashes
29. Basic Commands
● git stash pop
o go back to stashed state
● git mv [filename] [directory]
o move file to a different directory
o can be used to rename files
● git add [filename]
o create and add a file
30. Basic Commands
● git rm [filename]
o remove file
● git checkout [filename]
o get the committed version of file
o also used to reset or undelete file
31. Basic Commands
● gir reset [option] [pointer]
o move HEAD to pointer
o effectively move back in history
o HEAD~ = one back
o --soft - don’t delete “future” commits
o --mixed - remove uncommitted changes from
staging
default option
o --hard - delete “future” commits + staging
32. Basic Commands
● git tag -a ‘Name’ -m ‘Message’
o tag current HEAD, i.e. last commit
● git tag -1
o view tags
● git tag -d ‘Name’
o delete tag from local and from remote
33. Basic Commands
● git format-patch -1
o create patch files for the commit
● git apply [patch name]
o applies patch without creating commit
● git am [patch name]
o applies patch and creates commit
34. Basic Commands
● git branch
o see existing branches
● git branch [branch name]
o create a new branch pointing an current HEAD
● git checkout [branch name]
o switch to a different branch
● git checkout -b [branch name]
o create new branch at HEAD and switch to it