An introduction to version control using git, github and the Apache CloudStack git repository. Git is a distributed version control where developers can mantain a working local copy, make local changes and push to a central repository to share their code with other developers. Git has replaced SVN and CVS has the version control system of choice, especially with the adoption of github by the OSS community. In this talk we show the basics of version control, we use gist from github to put simple scripts under version control and submit patches to it. We then show how to clone the cloudstack repository, explore the various feature and release branches. We then show how to create a patch and submit it to the Apache Software Foundation review board so that a committer of the CloudStack community can pick it up and apply it to the source tree. This is the perfect talk to discover git and submit your first patch to CloudStack.
Text of Git 101 for CloudStack
1. Using Git 101 Sebas/en Goasguen @sebgoa
2. Outline Intro to version control and Git Crea/ng your rst git repo using Gist Cloning the CloudStack repo Managing branches Making your rst commit Applying a patch NB: Check the footnotes for addi/onal informa/on
3. Version Control Revision control (a.k.a version control) is the management of modica/ons of digital informa/on. In the context of soMware engineering it represents the management of the mul-ple versions of a so3ware as it evolves. In other terms it tracks changes in the source code. hOp://en.wikipedia.org/wiki/Revision_control
4. Version Control Systems Historically: Centralized systems used Concurrent Version System (CVS) Subversion (SVN) Currently: Distributed version control Git (2005) Mercurial/hg hOp://cvs.nongnu.org hOp://subversion.apache.org hOp://git-scm.com hOp://mercurial.selenic.com
5. Workow Developers clone a central repository Local repository is a working copy Updates are made locally (fast) When done, changes are pushed back to master Developers could push/hOp://i.stack.imgur.com/9IW5z.png pull to each other
6. Ge]ng Git Apache CloudStack (ACS) uses Git as distributed version control system Install git on your machine. Depending on your OS and package manager: ! !#yum install git-core! ! !#apt-get install git! ! !#port install git-core!
7. Tour GitHub Check the publicly accessible repositories Create an account Exercise: Check Gist Put a document under revision control hOps://github.com/repositories hOps://gist.github.com
8. Create a Gist Copy/Paste code or text in the main window, add a decrip/on. hOps://gist.github.com
9. See your rst version in the UI
10. Clone gist $git clone https://gist.github.com/5027212.git!Cloning into 5027212...!remote: Counting objects: 3, done.! remote: Compressing objects: 100% (2/2), done.! remote: Total 3 (delta 0), reused 0 (delta 0)!Unpacking objects: 100% (3/3), done.!$ cd 5027212/! $ ls! crawler.py! NB: Here crawler.py is just an example, you will have a dierent lename
11. Modify and Commit your Gist $ vi crawler.py !$ git add crawler.py !$ git commit -m "This is a gist test"! [master 578d363] This is a gist test! 1 file changed, 2 insertions(+)!$ git push!Username for https://gist.github.com: runseb! Password for https://[email protected]: ! Counting objects: 5, done.!Delta compression using up to 4 threads.!Compressing objects: 100% (2/2), done.!Writing objects: 100% (3/3), 312 bytes, done.!Total 3 (delta 1), reused 0 (delta 0)!To https://gist.github.com/5027212.git! 04d6d71..578d363 master -> master!
12. Explana/ons We opened the le and made some changes We made sure the changes were being tracked (git add). We commi:ed the changes to our local repository (git commit). To share these changes with others we pushed them to the remote repository (git push).
13. See the revisions
14. Browsing CloudStack Explore the latest commits, view the dis, browse the various branches hOps://git-wip-us.apache.org/repos/asf?p=incubator-cloudstack.git
15. Clone CloudStack git clone https://git-wip-us.apache.org/repos/asf/ incubator-cloudstack.git! Which branch are you on ? $ git branch! * master!
16. What is a branch ? A branch keeps track of a history of code changes. Mul/ple branches keep track of diverging histories of code changes. You can switch between branches to work on code changes without impac/ng another branch You can merge branches to unify histories