Patrick Cozzi University of Pennsylvania CIS 565 - Fall 2012 Source Control Primer Also called revision control or version control. Patrick Cozzi University of Pennsylvania CIS 565 - Fall 2012
Why Source Control? How do two people collaborate on the same code? Email? Dropbox? How do two hundred people collaborate?
Why Source Control? How do we backup our code? How do we change the same file? How do we get a history of changes?
Why Source Control? How do we make big or risky code changes without affecting the stable version? How do we work on new versions and still support old versions? Feature branches. Release branches.
Popular Tools P4 and SVN (subversion) are centralized. Git is distributed. Git is separate from github, but github is popular for hosting. Images from https://twitter.com/perforce, http://alagazam.net/, and https://twitter.com/GitHub
Centralized Server holds a centralized repository Clients have a revision This follows P4. The server has the entire repository (depot in P4) including history. Clients have a local snapshot.
Centralized This follows P4
Centralized This follows P4 Submit
Centralized This follows P4
Centralized Get Latest Revision
Centralized Modify/add/remove files Files can be read-only (P4) or not (SVN) Modify/add/remove files
Centralized Files can be read-only (P4) or not (SVN) Submit
Centralized Get Latest Revision
Distributed All machines have a full copy of the repository Repositories can be cloned Repositories can be pushed to and pulled from other machines
Distributed git init // Add files to directory git add * git commit –a –m ‘<description>’ Create a local repo Locally commit changes
Distributed Clone a remote repo git clone git@github.com:CIS565-Fall-2012/exampleProject.git Clone a remote repo
Distributed git commit –a –m ‘<description>’ Locally commit changes
Distributed git push Push changes to other repos
Distributed git pull Pull changes from other repos
Summary We are using git this semester - distributed source control Use source control for everything, not just code The initial pain will pay dividends for the rest of the semester and your career. Learn the command line, then use GUIs if desired.
Git Resources Create initial account - https://github.com/signup Get an edu account - https://github.com/edu Setup git - http://help.github.com/set-up-git-redirect/ Guide - http://rogerdudler.github.com/git-guide/ Cheat sheet - https://github.com/AlexZeitler/gitcheatsheet Join CIS 565 - https://github.com/CIS565-Fall-2012