Académique Documents
Professionnel Documents
Culture Documents
com
CONTENTS INCLUDE:
n
Distributed Version Control Concepts
n
and more...
If you are familiar with one or more traditional or centralized In a separation of concerns most satisfying to the purist,
version control systems like Subversion, there will be several Git does not directly support repository authentication or
mental adjustments to make in your migration to Git. The first authorization. It delegates this in a very functional way to the
is that there is no central server. The second is that there is no protocol (commonly SSH) or operating system (file system
central server. The full history of the repository lives on every permissions) hosting or serving up the repository. Thus, the
user’s machine that has cloned (checked out) a copy of the
repository. This is the essence of a Distributed Version Control
Getting Started with Git
System (DVCS).
Get over 90 DZone Refcardz
Once over those hurdles, it is quite liberating to be able to
work entirely independently, versioning any new project that
FREE from Refcardz.com!
you start, even if in the incubation phase. The ease of setting
up a new Git repository (or ‘repo’ in common parlance) leads
to setting up repos everywhere. It feels frictionless.
user information provided during your first Git setup on a given The protocol difference often signifies whether you have read-
machine is purely for “credit” of your code contributions. only or writeable access to the origin repository. The final
With the binaries on your $PATH, issue the following three syntax, which accesses an SSH exposed repository, is the most
commands just once per new machine on which you’ll be common write-enabled protocol.
using Git. Replace the username and email address with your The clone command performs several subtasks under the
preferred credentials. hood. It sets up a remote (a Git repository address bookmark)
git config --global user.name “matthew.mccullough”
named origin that points to the location
git config --global user.email “matthewm@ambientideas.com” git://github.com/matthewmccullough/hellogitworld.git. Next,
git config --global color.ui “auto”
clone asks this location for the contents of its entire repository.
These commands store your preferences in a file named Git copies those objects in a zlib-compressed manner over the
.gitconfig inside your home directory (~ on UNIX and Mac, and network to the requestor’s local disk. Lastly, clone switches to
%USERPROFILE% on Windows). a branch named master, which is equivalent to Subversion’s
If you are intrigued by all the potential nuances of a Git setup, trunk, as the current working copy. The local copy of this
GitHub, a web-based code hosting site, offers several in-depth repo is now ready to have edits made, branches created, and
tutorials on setting up Git for Linux, Windows, and Mac. Here commits issued – all while online or offline.
are several in-depth Git installation guides:
TREEISH & HASHES
http://help.github.com/win-git-installation/
http://help.github.com/mac-git-installation/
http://help.github.com/linux-git-installation/ Rather than a sequential revision ID, Git marks each commit
with a SHA-1 hash that is unique to the person committing the
Creating a Repository changes, the folders, and the files comprising the changeset.
Now that Git is installed and the user information established,
This allows commits to be made independent of any central
you can begin establishing new repositories. From a command
coordinating server.
prompt, change directories to either a blank folder or an
existing project that you want to put under version control. A full SHA-1 hash is 40 hex characters
Then initialize the directory as a Git repository by typing the 64de179becc3ed324daab72f7238df1404723672
following commands: To efficiently navigate the history of hashes, several symbolic
git init shorthand notations can be used as listed in the table below.
git add .
git commit –m’The first commit‘ Additionally, any unique sub-portion of the hash can be
used. Git will let you know when the characters supplied are
The first command in the sequence, init, builds a .git directory not enough to be unique. In most cases, 4-5 characters are
that contains all the metadata and repository history. Unlike sufficient.
many other version control systems, Git uniquely stores
Treeish Definition
everything in just a single directory at the top of the project.
No pollution in every directory. HEAD The current committed version
It is amazing and exciting to be able to truthfully say that you Treeish can be used in combination with all Git commands that
can use the basics of Git for locally versioning files with just accept a specific commit or range of commits.
these three commands. Examples include:
git log HEAD~3..HEAD
CLONING EXISTING PROJECTS git checkout HEAD^^
git merge RELEASE-1.0
If you need to move a file, Git can often detect your manual Log
relocation of the file and will show it as a pending “move.” The full list of changes since the beginning of time, or
However, it is often more prudent to just directly tell Git to optionally, since a certain date is right at your fingertips, even
relocate a file and track its new destination. when disconnected from all networks:
git mv originalfile.txt newsubdir/newfilename.txt git log
git log --since=yesterday
git log --since=2weeks
If you wish to expunge a file from the current state of the
branch, simply tell Git to remove it. It will be put in a pending
deletion state and can be confirmed and completed by the
next commit.
git rm fileyouwishtodelete.txt
Viewing
Daily work calls for strong support of viewing current and
historical facts about your repository, often from different,
perhaps even orthogonal points of view. Git satisfies those
demands in spades.
Blame
Status If trying to discover why and when a certain line was added, cut
To check the current status of a project’s local directories and to the chase and have Git annotate each line of a source file
files (modified, new, deleted, or untracked) invoke the status with the name and date it came into existence:
command: git blame <filename>
git status
Diff
A patch-style view of the difference between the currently Stashing
edited and committed files, or any two points in the past can Git offers a useful feature for those times when your changes
easily be summoned. The .. operator signifies a range is being are in an incomplete state, you aren’t ready to commit them,
provided. An omitted second element in the range implies a and you need to temporarily return to the last committed (e.g.
destination of the current committed state, also known a fresh checkout). This feature is named “stash” and pushes all
as HEAD: your uncommitted changes onto a stack.
git diff
git diff 32d4.. git stash
git diff --summary 32d4..
When you are ready to write the stashed changes back into the
Git allows for diffing between the local files, the stage files, and working copies of the files, simply pop them back of the stack.
the committed files with a great deal of precision.
git stash pop
Command Definition
Adding (Staging)
When the developer is ready to put files into the next commit,
they must be first staged with the add command. Users can
DZone, Inc. | www.dzone.com
4
Getting Started with Git
navigate to any directory, adding files item by item, or by git checkout -b <new branch name> <from branch>
wildcard.
Starting with Git 1.6.6, a shorthand notation can be used to
git add <file name, folder name, or wildcard>
git add submodule1/PrimaryClass.java track a remote branch with a local branch of exactly the same
git add .
git add *.java name when no local branch of that name already exists and
only one remote location is configured.
Specifying a folder name as the target of a git add git checkout <remote and local branch name>
git checkout performanceexperiment
recursively stages files in any subdirectories.
Listing Branches
The -i option activates interactive add mode, in which Git To list the complete set of current local and remote branches
prompts for the files to be added or excluded from the known to Git:
next commit. git branch -a
git add -i
Committing
Once all desired blobs are staged, a commit command
The local branches typically have simple names like master
transactionally saves the pending additions to the local
and experiment. Local branches are shown in white by Git’s
repository. The default text $EDITOR will be opened for entry
default syntax highlighting. Remote branches are prefixed by
of the commit message.
“remotes” and are shown in red.
git commit
Merging
To supply the commit message directly at the command prompt: Like other popular VCSes, Git allows you to merge one or more
git commit –m”<your commit message>” branches into the current branch.
git merge <branch one>
To view the statistics and facts about the last commit: git merge <branch one> <branch two>
git show
If any conflicts are encountered, which is rare with Git, a
If a mistake was made in the last commit’s message, edit the notification message is displayed and the files are internally
text while leaving the changed files as-is with: marked with >>>>>>>>> and <<<<<<<< around the
conflicting portion of the file contents. Once manually resolved,
git amend
git-add the resolved file, then commit in the usual manner.
Branching Rebase
Branching superficially appears much the same as it does in Rebasing is the rewinding of existing commits on a branch with
other version control systems, but the difference lies in the fact the intent of moving the “branch start point” forward, then
that Git branches can be targeted to exist only locally, or be replaying the rewound commits. This allows developers to test
shared with (pushed to) the rest of the team. The concept of their branch changes safely in isolation on their private branch
inexpensive local branches increases the frequency in which just as if they were made on top of the mainline code, including
developers use branching, opening it up to use for quick any recent mainline bug fixes.
private experiments that may be discarded if unsuccessful, or
git rebase <source branch name>
merged onto a well-known branch if successful. git rebase <source branch name> <destination branch name>
These diffs can be treated just like any other remote, even
Git repository sharing via the simple daemon is introduced at
though they are a local file on disk. The contents of the bundle
http://www.kernel.org/pub/software/scm/git/docs/git-daemon.html
can be inspected with Is-remote and the contents pulled
Sharing over SSH and Gitosis is documented in the Git into the local repository with fetch. Many Git users add a file
Community Book at
extension of .bundle as a matter of convention.
http://book.git-scm.com/4_setting_up_a_private_repository.html
git ls-remote catchupsusan.bundle
Remotes git fetch catchupsusan.bundle
IDEs
Java IDEs including IntelliJ, Eclipse (eGit), and NetBeans
(NBGit) all offer native or simple plugin support for Git through
their traditional source code control integration points.
Numerous other platform-native GUIs offer graphically rich
Fetch
history browsing, branch visualization, merging, staging and
To retrieve remote changes without merging them into your
commit features.
local branches, simply fetch the blobs. This invisibly stores all
retrieved objects locally in your .git directory at the top of your
A complete list of Git IDEs and GUIs can be found at:
project structure, but waits for further explicit instructions for a
http://delicious.com/matthew.mccullough/git+gui
source and destination of the merge.
git fetch <remote name>
git merge <remote name/remote branch>
CVS, SUBVERSION
Pull
Pulling is the combination of a fetch and a merge as per the On the interoperability front, the most amazing thing about Git
previous section all in one seamless action. is its ability to read and write to a remote Subversion or CVS
git pull
repository while aiming to provide the majority of the benefits
git pull <remote name> of Git on the local copy of a repository.
git pull <remote name> <branch name>
Cloning
Bundle To convert a Subversion repository that uses the traditional
Bundle prepares binary diffs for transport on a USB stick or via trunk, tags, branches structure into a Git repository, use a
email. These binary diffs can be used to “catch up” a repository syntax very similar to that used with a traditional Git repository.
that is behind otherwise too stringent of firewalls to successfully
git svn clone --stdlayout <svn repo url>
be reached directly over the network by push or pull.
git bundle create catchupsusan.bundle HEAD~8..HEAD Please be patient, and note the progress messages. Clones of
git bundle create catchupsusan.bundle --since=10.days master
large Subversion repositories can take hours to complete.
over a range of history that caused the unit tests to begin Pragmatic Version Control Using Git by Travis Swicegood.
failing, check the integrity of the repository with fsck, prune Printed by Pragmatic Programmers.
any orphaned blobs from the tree with gc, and search through http://pragprog.com/titles/tsgit/pragmatic-version-control-using-git
history with grep. And that is literally just the beginning.
Bookmarks
This quick overview demonstrates what a rich and deep DVCS Given the rapid pace of changes to the Git ecosystem, I
Git truly is, which still being approachable for the newcomer maintain a hand-culled list of the most informative pages on
to this bold new collaborative approach to source code and the Internet for the benefit of the Git community.
version control. http://delicious.com/matthew.mccullough/git
#82
CONTENTS INCLUDE:
■
■
About Cloud Computing
Usage Scenarios Getting Started with
Aldon Cloud#64Computing
■
Underlying Concepts
Cost
by...
■
Upcoming Refcardz
youTechnologies ®
■
Data
t toTier
brough Comply.
borate.
Platform Management and more...
■
Chan
ge. Colla By Daniel Rubio
tion:
dz. com
tegra ternvasll
ABOUT CLOUD COMPUTING one time events. TEN TS
INC ■
HTML LUD E:
us Ind Anti-PPaat
Basics
Automated growthHTM
ref car
nuorn
■
Valid
ation one time events, cloud ML
connected to what is now deemed the ‘cloud’. Having the capability to support
ul M.
computing platforms alsoulfacilitate
#84
Open the gradual growth curves
n an
Page Source
o
■
s
Vis it
C
faced by web applications. Tools
Core
By Key ■
Elem
Patte
has changed substantially in recent years, especially with Structur
E: al Elem ents
INC LUD gration the entrance of service providers like Amazon, Google and Large scale growth scenarios involvingents
specialized
NTS and mor equipment
rdz !
HTML
CO NTE Microsoft. es e... away by
(e.g. load balancers and clusters) are all but abstracted
Continu at Every e chang
m
About ns to isolat
relying on a cloud computing platform’s technology.
Software i-patter
space
■
n
Re fca
e Work
Build
riptio
and Ant
Desc
These companies have a Privat
are in long deployed
trol repos
itory
webmana applications
ge HTM
L BAS
■
Build
re
Buil Repo
This Refcard active
will introduce are within
to you to cloud riente computing, with an
d units
RATION etc. Some platforms ram support large grapRDBMS deployments.
■
The src
dy Ha
softw
e ine loping and Java s written in hical on of
INTEG attribute
task-o it all
softwar emphasis onDeve es by
Mainl these
ines providers, so youComm can better understand
also rece JavaScri user interfac web develop and the rris
Vis it
Network Security
codel chang desc
INUOU ding Task Level as the
e code
ww w.dzone.com
Label
Build
manu
al
d tool
depe deplo t need but as if
eve , a ) stalle the same nmen for stan overlap uen
(i.e. , inef Build t, use target enviro Amazon EC2: Industry standard it has
software and uagvirtualization ine. HTM , so <a>< tly are) nest
with terns problem ce pre-in whether dards
ated b></
ory. ns (i.e. Autom Redu ymen
has bec become e with a> is
via pat ticular d deploEAR) in each very little L
Maven 3
reposit -patter s that Pay only cieswhat you consume
tagge or Amazon’s cloud you cho platform
computing
the curr isome
heavily based moron fine. b></ ed insid
lained ) and anti the par solution duce nden For each (e.g. WAR es t
ent stan ose to writ more e imp a></ e
not lega each othe
x” b> is
be exp text to “fi are al Depeapplication deployment
Web ge until t a
librarifew years agonmen
t enviro was similar that will softwaredard
industry standard and virtualization app
e HTM technology.
orta nt,
tterns to pro Minim packa nden
Mo re
CI can ticular con used can rity all depe all targe
s will L or XHT arent. Reg the HTM l, but r. Tags
etimes Anti-pa they
tend
es, but to most phone services:
y Integ alizeplans with le that
late fialloted resources, ts with an and XHT simplify all help ML, und ardless
L VS
XHTM <a><
in a par hes som
Centr
end,
Binar
pro cess. the practic enti ng incurred costgeme
nt
whether e a single
such
temp
resources on
were consumed
t enviro
nmen
orthenot. Virtualization MLaare your
othe
you prov
erst of L
b></
in bad Mana based muchallows physical piece of hardware to
ide be HTM
approac ed with the cial, but, implem anding
Creat targe es to actually r web
rily nden
cy rties are nt
of the a solid L has
into differe coding.resources
necessa pared to
chang
efi Depe prope itting utilized by multiple operating
function systems.simplerThis allows foundati job adm been arou
associat to be ben
er
Ge t
te builds commo
are not Fortuna
late Verifi e comm than on
n com Cloud computing asRun it’sremo
known etoday has changed this.
befor alitytohas irably, nd for
They they
etc.
Temp Build (e.g. bandwidth, n memory, CPU) be allocated exclusively to tely exp that som
lts whe
ually,
appear effects. Privat y, contin Every elem mov used
to be, HTML
ecte job e time
ed resu The various resourcesPerfo rm a
consumed by webperio applications
dicall (e.g. nt team
pag
individual operating entsinstances. ed to CSS
system Brow d. Earl
y HTM has expand . Whi
gration
opme because
adverse unintend d Builds sitory Build r to devel common e (HTML . ser ed far le it has don
ous Inte web dev manufacture L had very
Stage Repo
e bandwidth, memory, CPU) areIntegtallied
ration on a per-unit CI serve basis or XHT
produc tinu e Build rm an from
extensio .) All are limited more than e its
e.com
ard ML shar
tern.
ack elopers rs add
Con Refc Privat
(starting from zero) by Perfo all majorated cloud
feedb computing platforms. As a user of Amazon’s esse
term e, this
on
n. HTM EC2 cloud
ntiallycomputing es certplatform, you are result
is a lack came up ed many com
layout anybody
the pat
occur
gration as based
of the ” cycl such Build Send
autom as they builds pr L plain ain elem supp
ous Inte tional use and test concepts
soon with clev ort.
Integ
ration ors as ion with text ents in of stan peting
entat
tinu dar er wor standar
ven “build include
docum
Con kar
the con s to the
oper
to rate devel
While efer of CI Gene
notion
DZone, Inc.
Cloud Computing
the
s on
expand
ISBN-13: 978-1-934238-75-2
140 Preston Executive Dr. ISBN-10: 1-934238-75-9
Suite 100
50795
Cary, NC 27513