0% found this document useful (0 votes)
6 views

01.2-VersionControl

The document provides an overview of version control in software development, highlighting its importance for both individual programmers and teams. It discusses various versioning models, vocabulary related to version control, and tools such as Git and jDiff. Additionally, it outlines the functionalities of version control systems and the process of managing changes in collaborative environments.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

01.2-VersionControl

The document provides an overview of version control in software development, highlighting its importance for both individual programmers and teams. It discusses various versioning models, vocabulary related to version control, and tools such as Git and jDiff. Additionally, it outlines the functionalities of version control systems and the process of managing changes in collaborative environments.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 51

1

ITSS SOFTWARE DEVELOPMENT


1-2. VERSION CONTROL
Nguyen Thi Thu Trang
trangntt@soict.hust.edu.vn
2

Outline
1. Introduction
2. Models
3. Vocabulary
4. Tools
3

Why version control? (1/2)


• Scenario 1:
• Your program is working
• You change “just one thing”
• Your program breaks
• You change it back
• Your program is still broken--why?

• Has this ever happened to you?


4

Why version control? (2/2)


• Your program worked well enough yesterday
• You made a lot of improvements last night...
• ...but you haven't gotten them to work yet
• You need to turn in your program now

• Has this ever happened to you?


5

Version control for teams (1/2)


• Scenario:
• You change one part of a program--it works
• Your co-worker changes another part--it works
• You put them together--it doesn’t work
• Some change in one part must have broken
something in the other part
• What were all the changes?
6

Version control for teams (2/2)


• Scenario:
• You make a number of improvements to a class
• Your co-worker makes a number of different
improvements to the same class
• How can you merge these changes?
7

Tools: diff
• There are a number of tools that help you spot
changes (differences) between two files
• Tools include diff, rcsdiff, jDiff, etc.
• Of course, they won't help unless you kept a copy
of the older version
• Differencing tools are useful for finding a small
number of differences in a few files
8

Tools: jDiff
• jDiff is a plugin for the jEdit editor
• Advantages:
• Everything is color coded
• Uses synchronized scrolling
• It's inside an editor--you can make changes directly
• Disadvantages:
• Not stand-alone, but must be used within jDiff
• Just a diff tool, not a complete solution
9

Tools: jDiff
10

Version control systems


• A version control system (often called a source
code control system) does these things:
• Keeps multiple (older and newer) versions of everything
(not just source code)
• Requests comments regarding every change
• Allows “check in” and “check out” of files so you know
which files someone else is working on
• Displays differences between versions
11

Outline
1. Introduction
2. Versioning Models
3. Vocabulary
4. Tools
12

2. Versioning Models
• Lock-Modify-Unlock
• Copy-Modify-Merge
• Distributed Version Control
13

2.1. The Lock-Modify-Unlock


he Lock-Modify-Unlock Model (1) Model
Andy and Bobby
check-out file A.
Repository
The check-out is done
without locking. They A
just get a local copy. Check-out

Check-out
A

Bobby
Andy
14

2.1. The Lock-Modify-Unlock


he Lock-Modify-Unlock Model (2)
Model (2)

Andy locks file A and Repository


begins modifying it.
A

Lock
A

Аndy

(Local Edit)
Bobby
Andy
15

2.1. The Lock-Modify-Unlock Model (3)


e Lock-Modify-Unlock Model (3)

Bobby tries to lock the


file too, but she can’t. Repository
Bobby waits for Andy to
A
finish and unlock the file. Wait

Andy

Bobby
Andy
16

2.1. The Lock-Modify-Unlock


he Lock-Modify-Unlock Model (4) Model (4)

Andy commits his changes Repository


and unlocks the file. Andy

Commit
A

Andy

Bobby
Andy
17

2.1. The Lock-Modify-Unlock


he Lock-Modify-Unlock Model (5) Model (5)

Now Bobby can take the


modified file and lock it. Repository
Bobby edits her local Andy
copy of the file. Lock

Andy

Andy
(Local Edit)

Bobby
Andy
18

ock-Modify-Unlock Model (6)


2.1. The Lock-Modify-Unlock Model (6)

Bobby finishes,
Repository
commits her changes
and unlocks the file. Andy
Bobby
Commit

Andy
Bobby

Andy

Bobby
Andy
19

ock-Modify-Unlock Model (7)


2.1. The Lock-Modify-Unlock Model (7)

Andy updates the


Repository
changes from the
repository. Andy
Bobby

Update Andy
Bobby

Andy
Bobby

Bobby
Andy
20

opy-Modify-Merge Model (1) Model


2.2. The Copy-Modify-Merge
Andy and Bobby
check-out a file A.
Repository
The check-out is
done without A
locking. Check-out

Check-out
A

Bobby
Andy
21

opy-Modify-Merge Model (2)


2.2. The Copy-Modify-Merge Model (2)
Both of them
edit the local
Repository
copies of the
file (in the A
same time).

Bobby

Andy
(Local Edit)

(Local Edit)
Bobby
Andy
22

opy-Modify-Merge Model (3)


2.2. The Copy-Modify-Merge Model (3)

Bobby commits Repository


her changes to
the repository. Bobby Commit

Bobby

Andy

Bobby
Andy
23

opy-Modify-Merge Model (4)


2.2. The Copy-Modify-Merge Model (4)
Andy tries to
commit his Repository
changes.
Bobby
A conflict occurs.

Commit Bobby
Bobby

Andy
Andy

(Local
Conflict) Bobby
Andy
24

2.2. The Copy-Modify-Merge


Copy-Modify-Merge Model (5) Model (5)
Andy updates his
changes with the ones
from the repository. Repository
The changes merge
into his local copy. Bobby

A merge conflict can


occur. Bobby

Andy
&
Bobby

(Local
Merge) Bobby
Andy
25

2.2. The Copy-Modify-Merge


e Copy-Modify-Merge Model (6)Model (6)
Andy commits the
merged changes to
the repository. Repository
A common version Andy
with the changes of &
Andy and Bobby is Bobby

inserted. Commit Bobby

Andy
&
Bobby

Bobby
Andy
26

2.2. The Copy-Modify-Merge


e Copy-Modify-Merge Model (7) Model (7)
Bobby updates the
changes from the
repository. Repository
She gets the common Andy
version with both & Update
changes from Andy Bobby
Andy
and Bobby. &
Bobby

Andy
&
Bobby

Bobby
Andy
27

2.3. Distributed version control


• Compared to Central version control
Centralized Version Control
• Only one repository
28

Distributed Version
tributed Version Control Control

//homes.cs.washington.edu/~mernst/advice/version-control.html
29

ributed Version Version


Distributed Control (1)
Control (1)
Andy and Bobby
clone the remote
repository locally. Remote
Repository
They both have the (Server)
A
same files in their
local repositories.
Clone Clone

A A

Local Local
Repository Repository
(Andy) (Bobby)
Andy
Bobby
30

buted Version Control (2)


Distributed Version Control (2)
Andy and Bobby Remote
work locally on a Repository
(Server)
certain file A. A

(Local Edit)
(Local Edit) Andy Bobby
A A

Local Local
Repository Repository
(Andy) (Bobby)
Andy
Bobby
31

ibuted Version Version


Distributed Control (3)
Control (3)
Andy and Bobby
commit locally the Remote
modified file A Repository
(Server)
into their local A
repositories.

Commit (locally) Commit (locally)

Andy Andy Bobby Bobby

Local Local
Repository Repository
(Andy) (Bobby)
Andy
Bobby
32

ibuted Version Version


Distributed Control (4)
Control (4)
Andy pushes the
file A to the remote Remote
repository. Repository
(Server)
Still no conflicts Andy
occur.
Push

Andy Andy Bobby Bobby

Local Local
Repository Repository
(Andy) (Bobby)
Andy
Bobby
33

ibuted Version Version


Distributed Control (5)
Control (5)
Bobby tries to push
her changes. Remote
Repository
A versioning conflict (Server)
Andy
occurs.

Push (conflict)

Andy Andy Bobby Bobby

Local Local
Repository Repository
(Andy) (Bobby)
Andy
Bobby
34

Distributed
tributed VersionVersion
Control Control
(6) (6)
Bobby merges the
her local files with
the files from the Remote
Repository
remote repository. (Server)
Andy
Conflicts are locally
resolved.
Pull (Fetch + Merge)

Andy Andy Bobby Bobby


+Andy +Andy

Local Local
Repository Repository
(Andy) (Bobby)
Andy
Bobby
35

ibuted Version Control (7)


Distributed Version Control (7)
Bobby commits her Remote
merged changes. Repository
(Server)
No version conflict. Bobby
Andy
+Andy

Push (no conflict)

Andy Andy Bobby Bobby


+Andy +Andy

Local Local
Repository Repository
(Andy) (Bobby)
Andy
Bobby
36

ributed VersionVersion
Distributed Control Control
(8) (8)
Andy pulls
(updates) the Remote
changed files Repository
(Server)
from the remote Bobby
Andy
+Andy
repository.
Pull

Bobby Bobby Bobby Bobby


+Andy +Andy +Andy +Andy

Local Local
Repository Repository
(Andy) (Bobby)
Andy
Bobby
37

Outline
1. Introduction
2. Versioning Models
3. Vocabulary
4. Tools
38

3. Vocabulary
• Repository (source control repository)
• A server that stores the files (documents)
• Keeps a change log
• Revision, Version
• Individual version (state) of a document that is a result of multiple
changes
• Check-Out, Clone
• Retrieves a working copy of the files from a remote repository into a
local directory
• It is possible to lock the files
39

Vocabulary
• Change
• A modification to a local file (document) that is under version
control
• Change Set / Change List
• A set of changes to multiple files that are going to be committed at
the same time
• Commit, Check-In
• Submits the changes made from the local working copy to the
repository
• Automatically creates a new version
• Conflicts may occur!
40

Vocabulary
• Conflict
• The simultaneous change to a certain file by multiple users
• Can be solved automatically and manually
• Update, Get Latest Version, Fetch / Pull
• Download the latest version of the files from the repository to a
local working directory + merge conflicting files
• Undo Check-Out, Revert / Undo Changes
• Cancels the local changes
• Restores their state from the repository
41

Vocabulary
• Merge
• Combines the changes to a file changed locally and simultaneously
in the repository
• Can be automated in most cases
• Label / Tag
• Labels mark with a name a group of files in a given version
• For example a release
• Branch / Branching
• Division of the repositories in a number of separate workflows
43

Outline
1. Introduction
2. Versioning Models
3. Vocabulary
4. Tools
44

Tools
• Central version control
• SVN (Subversion)
• TFS
• Source safe (commercial)
• Distributed version control
• Git
• Mercurial
45

What is Git?
• Git
• Distributed source-control system
• Work with local and remote repositories
• Git bash – command line interface for Git
• Free, open-source
• Has Windows version (msysGit)
• http://msysgit.github.io
• https://www.atlassian.com/git/tutorials/setting-up-a-repository
46

Installing Git
• msysGit Installation on Windows
• Download Git for Windows from: http://msysgit.github.io
• “Next, Next, Next” does the trick
• Options to select (they should be selected by default)
• “Use Git Bash only”
• “Checkout Windows-style, commit Unix-style endings”

• Git installation on Linux:


sudo apt-get install git
47

Basic Git Commands


• Cloning an existing Git repository
git clone [remote url]
• Fetch and merge the latest changes from the remote
repository
git pull
• Preparing (adding / selecting) files for a commit
git add [filename] ("git add ."adds everything)
• Committing to the local repository
git commit –m "[your message here]"
48

Basic Git Commands


• Check the status of your local repository (see the local
changes)
git status
• Creating a new local repository (in the current directory)
git init
• Creating a remote (assign a short name for remote Git
URL)
git remote add [remote name] [remote url]
• Pushing to a remote (send changes to the remote
repository)
git push [remote name] [local name]
49

Using Git: Example


mkdir work
cd work
git clone https://github.com/SoftUni/test.git dir
cd test
dir
git status
(edit some file)
git status
git add .
git commit -m "changes"
git push
50

Project Hosting Sites


• GitHub – https://github.com
• The #1 project hosting site in the world
• Free for open-source projects
• Paid plans for private projects
• GitHub provides own Windows client
• GitHub for Windows
• http://windows.github.com
• Dramatically simplifies Git
• For beginners only
51

Project Hosting Sites


• Google Code – http://code.google.com/projecthosting/
• Source control (SVN), file release, wiki, tracker
• Very simple, basic functions only, not feature-rich
• Free, all projects are public and open source
• 1-minute signup, without heavy approval process
• SourceForge – http://www.sourceforge.net
• Source control (SVN, Git, ...), web hosting, tracker, wiki, blog,
mailing lists, file release, statistics, etc.
• Free, all projects are public and open source
52

Project Hosting Sites


• CodePlex – http://www.codeplex.com
• Microsoft's open source projects site
• Team Foundation Server (TFS) infrastructure
• Source control (TFS), issue tracker, downloads, discussions, wiki,
etc.
• Free, all projects are public and open source
• Bitbucket – http://bitbucket.org
• Source control (Mercurial), issue tracker, wiki, management tools
• Private projects, free and paid editions

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy