140 likes | 328 Views
Source Control. You need it. The Plan for Today. You be able to explain what the goal of version control is You will have created an online git repository for your picassa project, and uploaded your files there. What Does Source Control Do Basically?.
E N D
Source Control You need it.
The Plan for Today • You be able to explain what the goal of version control is • You will have created an online git repository for your picassa project, and uploaded your files there
What Does Source Control Do Basically? • Keeps track of multiple versions of your files • That’s it • But this is a *revelation* https://github.com/elasticsearch/elasticsearch/tree/master/src/main/java/org/elasticsearch
Why is this important • Prevents old versions from being lost • Let’s multiple people work on the same code • You can build/compile old versions • You know who changed what when
There Are Many Kinds of Source Control • CVS – the old standard, now falling out of favor • SVN (or Subversion) – like CVS, but a little easier to use; Quite popular • Git – the new hotness • Mercurial – also new “Distributed” Version Control
Old “Non-Distributed” Version Control All versions of Source Code Central Server queries All commands go through the server. For example: Give me the code for version X Y Z Who changed this particular file? Insert my changes into the “latest good” version Get version
New “Distributed” Version Control Parent Source Code Server Copied to Synced up every now and then Local copy of the repository Get version Official repository is copied to local repository. Then all queries/changes get made to local repository. Give me the code for version X Y Z Who changed this particular file? Insert my changes into the “latest good” version Then, once everything is good… Local repository “pushes” all changes to the parent And “pulls” new changes pushed by others
We will be using git • Command line! • Please don’t use the git eclipse plugin! So many mysterious bugs…
Staging/Commit/Pushed • You edit a file • git add • You’ve added all you want • git commit • git push <remote> master
GIT Commands for Today • git init creates a new repository • git add <file/directory> adds a new file or directory to staging • git diff shows you changes you have not committed to staging add --cashed to see what changes are in staging • git commit -m “My message” commits your changes from staging to your local repository • git push <repo-name> <branch-name> pushes your changes from your local repository to a remote repository We haven’t discussed branches yet, so use “master” which is the main branch that is always automatically created for you