Академический Документы
Профессиональный Документы
Культура Документы
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
Software Engineering 2
Background [VCS]
[VCS] is a system that records the changes of a file
or set of files over time.
A [VCS] allows:
Software Engineering 2
Types of [VCSs]
Before [VCSs]
The method of many people to control versions was
to copy files into a directory by each version.
Where is the
last version?
Software Engineering 2
Types of [VCSs]
Local [VCSs]
These systems had a simple database that kept all the
changes to files under revision control.
[BOOK] ProGit
Software Engineering 2
Types of [VCSs]
Centralized [VCSs]
These systems have a single server that contains all
the versioned files and a number of clients that check
out files from that central place.
[BOOK] ProGit
Software Engineering 2
Types of [VCSs]
Distributed [VCSs]
In these systems the clients dont just check out the
latest snapshot of the files, they fully mirror the
repository.
[BOOK] ProGit
Software Engineering 2
Software Engineering 2
Terminology
Term
Description
Software Engineering 2
Terminology
Term
Description
Commit
URL
Revision
HEAD
Software Engineering 2
Software Engineering 2
Git
Other
systems
[BOOK] ProGit
Git
[BOOK] ProGit
Software Engineering 2
Git Features
Nearly every operation is local.
Git has Integrity.
Git generally only
adds data.
The 3 states:
Modified
Staged
C0mmitted
[BOOK] ProGit
Software Engineering 2
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 not
been staged Modified.
If a file is modified but has been added to the staging
area Staged.
If a version of a file is in the Git directory Committed.
Software Engineering 2
Installing Git
http://git-scm.com/book/en/Getting-StartedInstalling-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
Software Engineering 2
Software Engineering 2
Software Engineering 2
Register Changes
Background file status
[BOOK] ProGit
Software Engineering 2
Class Exercise
1. When you first clone a repository, what is the
state of all files?
2. When you add a file to working
copy, what is the state of this file?
3. When you edit a tracked file, what is the state of
this file?
Software Engineering 2
Register Changes
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 <file>..." to include in what will
be committed)
README nothing added to commit but
files present (use "git add" to track)
untracked
Software Engineering 2
Register Changes
Tracking new files
$ git add README
git status
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
new file: README
Software Engineering 2
Register Changes
Viewing staged and unstaged changes
[BOOK] ProGit
Software Engineering 2
Register Changes
Committing changes
$ git commit m a message
$ git commit -m "Story 182: Fix
[master]: created 463dc4f: Fix
2 files changed, 3 insertions(+),
create mode 100644 README
0 deletions(-)
Register Changes
Removing files
$ git rm [file]
git rm README.txt
git status
On branch master
Changes not staged for commit:
(use "git add/rm <file>..." to update what
will be committed)
# deleted: README.txt
Software Engineering 2
Software Engineering 2
[BOOK] ProGit
Software Engineering 2
Software Engineering 2
Software Engineering 2
Adding remotes
git remote add [shortname] [url]
Software Engineering 2
Pushing to remotes
$ git push [remote-name] [branch-name]
Software Engineering 2
Software Engineering 2
Tagging
Git has the ability to tag specific points in history as
being important.
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
Software Engineering 2
Software Engineering 2
Git Branching
Branching is a mechanism to diverge from the main
line 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
Git Branching
Lets assume that we have a directory containing
three files, and we stage them all and commit.
[BOOK] ProGit
Software Engineering 2
Git Branching
After two more commits the history might look
something like as:
[BOOK] ProGit
Software Engineering 2
Software Engineering 2
Git Branching
[BOOK] ProGit
A shorthand
$ git checkout -b testing
Software Engineering 2
Git Branching
$ vim test.rb
$ git commit -a -m 'made a change'
[BOOK] ProGit
Software Engineering 2
Class Exercise
1. What happen if we make a few changes and
commit again?
[BOOK] ProGit
Software Engineering 2
Solution Exercise
[BOOK] ProGit
Software Engineering 2
Class Exercise
1. Define the
workflow:
1.
2.
3.
4.
5.
6.
commands
necessary
to
next
Software Engineering 2
Solution
[BOOK] ProGit
Software Engineering 2
[BOOK] ProGit
Software Engineering 2
Merging
Suppose that after hotfix is tested, we want to
merge hotfix to master.
[BOOK] ProGit
Software Engineering 2
Merging
Remember iss53 branch. Suppose weve decided
that our iss53 work is complete and ready to be
merged into the master branch.
What is the difference?
Vs
Software Engineering 2
Merging
Software Engineering 2
Hosting SD Services
GitHub is a web based hosting
service for software development
projects that use the Git revision
control system.
Google Code is Google's site for
developer tools, APIs and technical
resources.
SourceForge is a web-based source
code repository.
Software Engineering 2
Assignment 5
Choose a VCS to develop your project and publish
how to clone the repository in the versioning
section of your project page.
Read Section 5.1 of the ProGit Book, because next
we 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.
Software Engineering 2