versionControl/handOut.rst
author Shantanu <shantanu@fossee.in>
Fri, 21 Aug 2009 00:20:24 +0530
changeset 8 461e2574d624
parent 7 eef24e2b0bac
child 15 d20e3fe4fd8c
permissions -rw-r--r--
Added CVCS and DVCS subsection.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
     1
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
     2
Version Control
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
     3
===============
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
     4
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
     5
Introduction
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
     6
------------
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
     7
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
     8
The following words are from a blogpost "http://karlagius.com/2009/01/09/version-control-for-the-masses/"
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
     9
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    10
"Version control is one of those weird, geeky things that never really gained much ground in non-geek fields, despite the fact that it’s blindingly useful.
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    11
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    12
Version control (or source control) is nothing more arcane than keeping copies of ones work as one make changes to it. On the surface, it’s all straight-forward; make a copy of every file before making any changes to it. That way, if something seriously messes up, one can always fall back to something that worked before, or at least compare the broken copy with one that used to work so one can figure out where it went off kilter.Accidentally deleted half of thesis and closed the word processor? No problem – out comes the backup."
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    13
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    14
Now, in the real world, it’s not so easy. One probably cooks up their own version control system without realizing it had such a geeky name. For instances files with names oldxxxxxx.odt and latestxxxxxx.odt. Every time to make some change in a file, one save it with different name then the original one. Luckily there are like, loads of version control systems out there to do this heavy lifting.
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    15
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    16
Why Use Version Control
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    17
-----------------------
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    18
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    19
"Its the start which most people fail to attempt". 
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    20
One of idea behind Version Control Tools was to save that "one" step, to build onto it, rather then simply lose it. So here are some reasons why is automated version control needed:
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    21
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    22
    - It will track the history and evolution of a project, so one don't have to do it manually. It allows to track what changes where made, when were they made, by whom and why.
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    23
    - For a team on people working on same project, revision control software makes it easier to collaborate. For example, when people more or less simultaneously make potentially incompatible changes, the software will help them to identify and resolve those conflicts.
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    24
    - It can help to recover from mistakes. If a change made at some moment of time, turns out to be in error in future, one can revert to an earlier version of one or more files. In fact, a really good revision control tool will even help in efficiently figure out exactly when a problem was introduced.
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    25
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    26
Most of these reasons are equally valid for the project having one man show, or hundred people. Beyond this, even it can be used to maintain assignments related to one particular subject/course, it will help manage things in way much better way. Rather use these tools for *resource management*. All codes, documents, presentation, assignments related to one course maintained in such a inventory,and one would never need (excuse)/(face the embarrassament), "I accendently deleted my all data!"(for those who have actually done that after completing assignments), and Internet hosting for version control will make the work immune to local hard-disk crash, unless hosting crashes itself.
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    27
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    28
Some of Version Control Tools available and used widely are:
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    29
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    30
     - cvs (Concurrent Version System)
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    31
     - svn (Subversion)
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    32
     - hg (Mercurial)
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    33
     - bzr (Bazaar)
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    34
     - git 
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    35
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    36
Each of above mentioned tools have sets of feature which it offers in unique way. For this session we are going to concentrate on hg (mercurial). After covering the basics of hg, one can easily try other tools, and use what-ever he/she is most comfortable with.
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    37
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    38
Learning the Lingo
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    39
------------------
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    40
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    41
Each Version Control uses its own nomenclature for more or less the same features. Here are some of terms which are going to used through out the rest of session:
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    42
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    43
Basic Setup
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    44
~~~~~~~~~~~
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    45
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    46
     Repository(repo):
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    47
	The database/folder storing the files.
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    48
     Server:
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    49
	The computer storing the repo.
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    50
     Client:
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    51
	The computer connecting to the repo.
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    52
     Working Set/Working Copy:
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    53
     	Your local directory of files, where you make changes. This is what is present on client side.
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    54
     Trunk/Main:
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    55
	The “primary” location for code in the repo. Think of code as a family tree — the “trunk” is the main line. This is generally what is present on server.
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    56
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    57
Basic Actions
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    58
~~~~~~~~~~~~~
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    59
     
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    60
     Add:
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    61
	Put a file into the repo for the first time, i.e. begin tracking it with Version Control.
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    62
     Revision:
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    63
	What version a file is on.
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    64
     Head:
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    65
	The latest revision of the repo.
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    66
     Check out:
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    67
     	Initial download of repo onto machine.
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    68
     Check in:
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    69
     	Upload a file to repository(if it has changed). The file gets a new revision number, and people can “check out” the latest one.
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    70
     Checkin Message:
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    71
     	A short message describing what was changed.
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    72
     Changelog/History:
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    73
	A list of changes made to a file since it was created.
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    74
     Update/Sync:
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    75
	Synchronize local files with the latest from the repository on server. This get the latest revisions of all files.
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    76
     Revert:
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    77
	Throw away the local changes and reload the latest version from the repository.
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    78
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    79
Advanced Actions:
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    80
~~~~~~~~~~~~~~~~~
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    81
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    82
     Branch:
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    83
	Create a separate copy of a file/folder for private use (bug fixing, testing, etc).
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    84
     Diff/Change:
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    85
	Finding the differences between two files. Useful for seeing what changed between revisions.
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    86
     Merge (or patch):
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    87
     	Apply the changes from one file to another, to bring it up-to-date.
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    88
     Conflict:
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    89
	When pending changes to a file contradict each other (both changes cannot be applied).
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    90
     Resolve:
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    91
	Fixing the changes that contradict each other and checking in the correct version.
eef24e2b0bac Hand out doc for version contol added.
Shantanu <shantanu@fossee.in>
parents:
diff changeset
    92
     
8
461e2574d624 Added CVCS and DVCS subsection.
Shantanu <shantanu@fossee.in>
parents: 7
diff changeset
    93
Types of Version Control:
461e2574d624 Added CVCS and DVCS subsection.
Shantanu <shantanu@fossee.in>
parents: 7
diff changeset
    94
~~~~~~~~~~~~~~~~~~~~~~~~~
461e2574d624 Added CVCS and DVCS subsection.
Shantanu <shantanu@fossee.in>
parents: 7
diff changeset
    95
461e2574d624 Added CVCS and DVCS subsection.
Shantanu <shantanu@fossee.in>
parents: 7
diff changeset
    96
Based on how source management is carried out in a tool there are two categories of Version Control Systems(VCS):
461e2574d624 Added CVCS and DVCS subsection.
Shantanu <shantanu@fossee.in>
parents: 7
diff changeset
    97
461e2574d624 Added CVCS and DVCS subsection.
Shantanu <shantanu@fossee.in>
parents: 7
diff changeset
    98
      - Centralized VCS: 
461e2574d624 Added CVCS and DVCS subsection.
Shantanu <shantanu@fossee.in>
parents: 7
diff changeset
    99
      	In this kind of system all the revision control functions are performed on a shared server. If two developers try to change the same file at the same time, without some method of managing access the developers may end up overwriting each other's work. Centralized revision control systems solve this problem in one of two different "source management models": file locking and version merging. Both svn and cvs follows this kind of management.
461e2574d624 Added CVCS and DVCS subsection.
Shantanu <shantanu@fossee.in>
parents: 7
diff changeset
   100
   
461e2574d624 Added CVCS and DVCS subsection.
Shantanu <shantanu@fossee.in>
parents: 7
diff changeset
   101
      - Distributed VCS:
461e2574d624 Added CVCS and DVCS subsection.
Shantanu <shantanu@fossee.in>
parents: 7
diff changeset
   102
      	In a distributed model, every developer has their own repo. Diffs, commits, and reverts are all done locally, one needs Internet only to share the changes with others. It makes work faster, handles branching and merging in better way, with less management. hg, bzr and git uses this workflow.
461e2574d624 Added CVCS and DVCS subsection.
Shantanu <shantanu@fossee.in>
parents: 7
diff changeset
   103
461e2574d624 Added CVCS and DVCS subsection.
Shantanu <shantanu@fossee.in>
parents: 7
diff changeset
   104
461e2574d624 Added CVCS and DVCS subsection.
Shantanu <shantanu@fossee.in>
parents: 7
diff changeset
   105
Suggested Reading:
461e2574d624 Added CVCS and DVCS subsection.
Shantanu <shantanu@fossee.in>
parents: 7
diff changeset
   106
------------------
461e2574d624 Added CVCS and DVCS subsection.
Shantanu <shantanu@fossee.in>
parents: 7
diff changeset
   107
461e2574d624 Added CVCS and DVCS subsection.
Shantanu <shantanu@fossee.in>
parents: 7
diff changeset
   108
	* http://karlagius.com/2009/01/09/version-control-for-the-masses/
461e2574d624 Added CVCS and DVCS subsection.
Shantanu <shantanu@fossee.in>
parents: 7
diff changeset
   109
	* http://betterexplained.com/articles/a-visual-guide-to-version-control/
461e2574d624 Added CVCS and DVCS subsection.
Shantanu <shantanu@fossee.in>
parents: 7
diff changeset
   110
	* http://en.wikipedia.org/wiki/Revision_control
461e2574d624 Added CVCS and DVCS subsection.
Shantanu <shantanu@fossee.in>
parents: 7
diff changeset
   111
	* http://hgbook.red-bean.com/
461e2574d624 Added CVCS and DVCS subsection.
Shantanu <shantanu@fossee.in>
parents: 7
diff changeset
   112
	* http://betterexplained.com/articles/intro-to-distributed-version-control-illustrated/