S2 Version Control Systems
-
Upload
ivan-ceballos -
Category
Documents
-
view
218 -
download
0
Transcript of S2 Version Control Systems
-
8/17/2019 S2 Version Control Systems
1/52
Version Control SystemsYury Yineth Niño Roa
Software Engineering 2
UNIVERSIDAD NACIONAL DE COLOMBIA
-
8/17/2019 S2 Version Control Systems
2/52
Content
• Version Control Systems
• Git Basics
• Installing Git
• Getting a Git repository
• Recording changes to the repository
• Viewing the commit history
• Branching and Merging
Software Engineering 2
-
8/17/2019 S2 Version Control Systems
3/52
What is Version Control System[VCS]?
Software Engineering 2
-
8/17/2019 S2 Version Control Systems
4/52
Background [VCS]
• [VCS] is a system that records the changes of a fileor set of files over time.
•
A [VCS] allows: – Revert files back to a previous state.
– Revert the entire project back to a previous state.
– Review changes made over time.
– See who last modified something.
• There are 3 types of [VCSs].
Software Engineering 2
-
8/17/2019 S2 Version Control Systems
5/52
What are the types of [VCSs]?
Software Engineering 2
-
8/17/2019 S2 Version Control Systems
6/52
Types of [VCSs]
• Before [VCSs]
The method of many people to control versions wasto copy files into a directory by each version.
Software Engineering 2
Where is the
last version?
-
8/17/2019 S2 Version Control Systems
7/52
Types of [VCSs]
• Local [VCSs]
These systems had a simple database that kept all thechanges to files under revision control.
Software Engineering 2
[BOOK] ProGit
-
8/17/2019 S2 Version Control Systems
8/52
Types of [VCSs]
• Centralized [VCSs]
These systems have a single server that contains allthe versioned files and a number of clients that check
out files from that central place.
Software Engineering 2
[BOOK] ProGit
-
8/17/2019 S2 Version Control Systems
9/52
Types of [VCSs]
• Distributed [VCSs]
In these systems the clients don’t just check out thelatest snapshot of the files, they fully mirror the
repository.
Software Engineering 2
[BOOK] ProGit
-
8/17/2019 S2 Version Control Systems
10/52
I don’t understand several terms
Software Engineering 2
-
8/17/2019 S2 Version Control Systems
11/52
Terminology
Software Engineering 2
Term Description
RepositoryContains the history, versions over time, branches andtags.Each copy of the repository is a complete repository.
Workingtree
Contains the content of a commit which you cancheckout.
Branch Is a separate code line with its own history.
One of the branches is the default (master).
Tag Points to a commit which uniquely identifies a version
of the repository.
[URL] http://www.vogella.com/articles/Git/article.html
-
8/17/2019 S2 Version Control Systems
12/52
Terminology
Software Engineering 2
Term Description
CommitAn user commit his changes into a repository.A new commit uniquely identifies a new revision ofthe repository.
URL An URL determines the location of the repository.
Revision Represents a version of the source code.
HEAD Is a pointer to the currently selected commit object
[URL] http://www.vogella.com/articles/Git/article.html
-
8/17/2019 S2 Version Control Systems
13/52
How does Git work?
Software Engineering 2
-
8/17/2019 S2 Version Control Systems
14/52
Git
Software Engineering 2
Other
systems
Git
[BOOK] ProGit
[BOOK] ProGit
-
8/17/2019 S2 Version Control Systems
15/52
Git Features
• Nearly every operation is local.
• Git has Integrity.
• Git generally onlyadds data.
• The 3 states:
– Modified – Staged
– C0mmitted
Software Engineering 2
[BOOK] ProGit
-
8/17/2019 S2 Version Control Systems
16/52
Git Features
• A Git workflow like this:
– A user modifies files in the working directory.
– A user stages the files.
– A user does a commit.
– If it was changed since it was checked out but has notbeen staged – Modified.
– If a file is modified but has been added to the stagingarea – Staged.
– If a version of a file is in the Git directory – Committed.
Software Engineering 2
-
8/17/2019 S2 Version Control Systems
17/52
Installing Git
• http://git-scm.com/book/en/Getting-Started-Installing-Git#Installing-from-Source
•
On Linux – $ apt-get install git
• On Windows – Download the installer .exe file from the GitHub page and
run it:
http://msysgit.github.com/
Software Engineering 2
http://git-scm.com/book/en/Getting-Started-Installing-Githttp://git-scm.com/book/en/Getting-Started-Installing-Githttp://msysgit.github.com/http://msysgit.github.com/http://msysgit.github.com/http://msysgit.github.com/http://msysgit.github.com/http://msysgit.github.com/http://msysgit.github.com/http://msysgit.github.com/http://git-scm.com/book/en/Getting-Started-Installing-Githttp://git-scm.com/book/en/Getting-Started-Installing-Githttp://git-scm.com/book/en/Getting-Started-Installing-Githttp://git-scm.com/book/en/Getting-Started-Installing-Githttp://git-scm.com/book/en/Getting-Started-Installing-Githttp://git-scm.com/book/en/Getting-Started-Installing-Githttp://git-scm.com/book/en/Getting-Started-Installing-Githttp://git-scm.com/book/en/Getting-Started-Installing-Githttp://git-scm.com/book/en/Getting-Started-Installing-Githttp://git-scm.com/book/en/Getting-Started-Installing-Githttp://git-scm.com/book/en/Getting-Started-Installing-Githttp://git-scm.com/book/en/Getting-Started-Installing-Githttp://git-scm.com/book/en/Getting-Started-Installing-Githttp://git-scm.com/book/en/Getting-Started-Installing-Githttp://git-scm.com/book/en/Getting-Started-Installing-Githttp://git-scm.com/book/en/Getting-Started-Installing-Githttp://git-scm.com/book/en/Getting-Started-Installing-Git
-
8/17/2019 S2 Version Control Systems
18/52
First-Time Git Setup
• Checking your settings$ git config –list
• Setting your identity$ git config --global user.name “Yury“
$ git config --global user.email [email protected]
• Choose diff tool$ git config --global merge.tool vimdiff
You can choose kdiff3, tkdiff, meld, xxdiff, emerge, vimdiff, gvimdiff,ecmerge, and opendiff as ddiff tool.
Software Engineering 2
-
8/17/2019 S2 Version Control Systems
19/52
Getting a Git Repository
• There are 2 approaches: – Take an existing directory and import it into Git.
– Clone an existing Git repository from another server.
• Initializing a repository in an existing directory$ git init
$ git add .
$ git commit -m „initial project version‟
• Cloning an existing repository$ git clone git://github.com/davidmr/scio.git
Software Engineering 2
-
8/17/2019 S2 Version Control Systems
20/52
How to register changes?
Software Engineering 2
-
8/17/2019 S2 Version Control Systems
21/52
Register Changes
Software Engineering 2
• Background file status
[BOOK] ProGit
-
8/17/2019 S2 Version Control Systems
22/52
Class Exercise
Software Engineering 2
1. When you first clone a repository, what is thestate of all files?
2. When you add a file to workingcopy, what is the state of this file?
3. When you edit a tracked file, what is the state ofthis file?
-
8/17/2019 S2 Version Control Systems
23/52
Register Changes
Software Engineering 2
• Checking the status of files$ git status# On branch master nothing to commit(working directory clean)
• If README is added$ git status# On branch master# Untracked files:# (use "git add ..." to include in what will
be committed)## README nothing added to commit but untracked
files present (use "git add" to track)
-
8/17/2019 S2 Version Control Systems
24/52
Register Changes
Software Engineering 2
• Tracking new files$ git add README
• If run status again$ git status# On branch master
# Changes to be committed:
# (use "git reset HEAD ..." to unstage)
#
# new file: README#
-
8/17/2019 S2 Version Control Systems
25/52
Register Changes
Software Engineering 2
• Viewing staged and unstaged changes
[BOOK] ProGit
-
8/17/2019 S2 Version Control Systems
26/52
Register Changes
Software Engineering 2
• Committing changes$ git commit – m “a message”
$ git commit -m "Story 182: Fix“
[master]: created 463dc4f: “Fix“2 files changed, 3 insertions(+), 0 deletions(-)create mode 100644 README
•
You can see in the output commit: – Which branch you committed to (master).
– What SHA-1 checksum the commit has (463dc4f).
– How many files were changed.
-
8/17/2019 S2 Version Control Systems
27/52
Register Changes
Software Engineering 2
• Removing files$ git rm [file]
• The file is only removed from the working directory:$ git rm README.txt
$ git status
# On branch master
# Changes not staged for commit:# (use "git add/rm ..." to update what
will be committed)
# deleted: README.txt
-
8/17/2019 S2 Version Control Systems
28/52
How to view the commithistory?
Software Engineering 2
-
8/17/2019 S2 Version Control Systems
29/52
Viewing the Commit History
• The most basic and powerful tool to do this is:$ git log
Software Engineering 2
[BOOK] ProGit
-
8/17/2019 S2 Version Control Systems
30/52
Viewing the Commit History
Software Engineering 2
• Using Gitk or Git GUI
-
8/17/2019 S2 Version Control Systems
31/52
I want to be able to collaborateon any Git project? Is it possible?
Software Engineering 2
-
8/17/2019 S2 Version Control Systems
32/52
Working with Remotes
• Remote repositories are versions of the project thatare hosted on the Internet or network somewhere.
• Collaborating with others involves managing these
remote repositories, pushing and pulling data to andfrom them.
• Showing remotes
git remote
• Adding remotesgit remote add [shortname] [url]
Software Engineering 2
-
8/17/2019 S2 Version Control Systems
33/52
Working with Remotes
• Fetching to remotes$ git fetch [remote-name]
fetch command doesn’t automatically merge local work with the
remote. It’s necessary to merge manually.
$ git pull [remote-name]
• Pushing to remotes$ git push [remote-name] [branch-name]
Software Engineering 2
-
8/17/2019 S2 Version Control Systems
34/52
Is possible tagging releases inGit?
Because in SVN is possible
Software Engineering 2
-
8/17/2019 S2 Version Control Systems
35/52
Tagging
• Git has the ability to tag specific points in history asbeing important.
Software Engineering 2
• Listing tags$ git tag
v0.1
v1.3
•
Lightweight tags$ git tag v1.4-lw
• Creating Tags
– Lightweight
– Annotated
•
Annotated tags$ git tag -a v1.4-m 'my version 1.4‟
-
8/17/2019 S2 Version Control Systems
36/52
Before we finish, Can we reviewbranching?
Software Engineering 2
-
8/17/2019 S2 Version Control Systems
37/52
Git Branching
• Branching is a mechanism to diverge from the mainline of development and continue to do work.
•
When a user commit, Git stores a object with: – A pointer to the snapshot of the content staged.
– The author and message metadata.
– Zero or more pointers to the commit or commits that
were the direct parents of this commit.
Software Engineering 2
-
8/17/2019 S2 Version Control Systems
38/52
Git Branching
Software Engineering 2
• Let’s assume that we have a directory containingthree files, and we stage them all and commit.
[BOOK] ProGit
-
8/17/2019 S2 Version Control Systems
39/52
Git Branching
Software Engineering 2
• After two more commits the history might looksomething like as:
[BOOK] ProGit
-
8/17/2019 S2 Version Control Systems
40/52
What happens if we create anew branch?
Software Engineering 2
-
8/17/2019 S2 Version Control Systems
41/52
Git Branching
Software Engineering 2
• $ git branch testing
$ git checkout testing
• A shorthand$ git checkout -b testing
[BOOK] ProGit
-
8/17/2019 S2 Version Control Systems
42/52
Git Branching
Software Engineering 2
• $ vim test.rb
$ git commit -a -m 'made a change'
$ git checkout master
[BOOK] ProGit
-
8/17/2019 S2 Version Control Systems
43/52
Class Exercise
Software Engineering 2
1. What happen if we make a few changes andcommit again?
[BOOK] ProGit
-
8/17/2019 S2 Version Control Systems
44/52
Solution Exercise
Software Engineering 2
[BOOK] ProGit
-
8/17/2019 S2 Version Control Systems
45/52
Class Exercise
Software Engineering 2
1. Define the commands necessary to nextworkflow:
1. Clone a project that is hosting in
git://github.com/yyninor/myweb.git2. Do work on a web site.
3. Publish these changes in the remote.
4. Create a branch for a new story you’ll working on.
5. Do some work in that branch.6. Publish these changes in your local repository.
-
8/17/2019 S2 Version Control Systems
46/52
Solution
Software Engineering 2
[BOOK] ProGit
-
8/17/2019 S2 Version Control Systems
47/52
Creating new branch hotfix
Software Engineering 2
[BOOK] ProGit
• Suppose that we have to create a new branchhotfix from master.
-
8/17/2019 S2 Version Control Systems
48/52
Merging
• Suppose that after hotfix is tested, we want tomerge hotfix to master.
Software Engineering 2
[BOOK] ProGit
-
8/17/2019 S2 Version Control Systems
49/52
Merging
• Remember iss53 branch. Suppose we’ve decidedthat our iss53 work is complete and ready to bemerged into the master branch.
What is the difference
Software Engineering 2
Vs
-
8/17/2019 S2 Version Control Systems
50/52
Merging
Software Engineering 2
-
8/17/2019 S2 Version Control Systems
51/52
Hosting SD Services
GitHub is a web – based hostingservice for software developmentprojects that use the Git revision
control system.Google Code is Google's site for
developer tools, APIs and technicalresources.
SourceForge is a web-based sourcecode repository.
Software Engineering 2
-
8/17/2019 S2 Version Control Systems
52/52
Assignment 5
• Choose a VCS to develop your project and publishhow to clone the repository in the versioningsection of your project page.
• Read Section 5.1 of the ProGit Book, because nextwe will make a quiz about this topic.
• Decide what workflow are you going
to use within your project. Justify
your answer in the versioning section.