Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Save to My Library
Look up keyword
Like this
7Activity
0 of .
Results for:
No results containing your search query
P. 1
A Tour of git - The Basics

A Tour of git - The Basics

Ratings:

4.4

(5)
|Views: 581 |Likes:
Published by Oleksiy Kovyrin

More info:

Published by: Oleksiy Kovyrin on Apr 12, 2008
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

11/14/2013

pdf

text

original

 
A tour of git: the basics
A tour of git: the basics
2.0 Copyright
This document is a modified version of a document originally titled "Distributed revision controlwith Mercurial" and originally authored by Bryan O’Sullivan. The original document wasobtained fromhttp://hgbook.red-bean.com/.Copyright © 2006, 2007 Bryan O’Sullivan.This material may be distributed only subject to the terms and conditions set forth in version1.0 of the Open Publication License. Please refer to Appendix D for the license text.As this is a modified version, the name of Bryan O'Sullivan is used only to properly credit himwith the original text. The appearance of his name here explicitly does not assert or imply hisendorsement of this modified document.Portions Copyright © 2007 Carl Worth.Changes made by Carl include the following:2007-09-27:Convert from HTML to markdown source syntaxEliminate all content except Chapter 2 and Appendix DEliminate line numbers from examplesModified to describe git instead of mercurialThe source of this modified version can be obtained via git:
git clone git://cworth.org/git/hgbook-git
or
git clone http://cworth.org/git/hgbook-git
and can bebrowsed online
2.1 Installing git on your system
Prebuilt binary packages of git are available for many popular operating systems. These make iteasy to start using git on your computer immediately.
2.1.1 Linux
Because each Linux distribution has its own packaging tools, policies, and rate of development,it’s difficult to give a comprehensive set of instructions on how to install git binaries. Theversion of git that you will end up with can vary depending on how active the person is whomaintains the package for your distribution.To keep things simple, I will focus on installing git from the command line under the most
A tour of git: the basicshttp://cworth.org/hgbook-git/tour/1 of 234/11/08 7:21 PM
 
popular Linux distributions. Most of these distributions provide graphical package managers thatwill let you install git with a single click. The package name to look for is often git, but issometimes git-core, (due to an unfortunate name with git, meaning GNU Interactive Tools).Debianapt-get install git-coreFedora Coreyum install gitGentooemerge dev-util/gitOpenSUSEyum install gitUbuntuapt-get install git-core
2.1.2 Mac OS X
A git-core package is available throughmacports. Once macports is enabled, the command toinstall git is:
port install git-core
2.1.3 Windows
Git has long been available as part of cygwin, and works reasonably well in that environment.Some people find cygwin a particularly inelegant approach to running git and would prefer a"native" solution. To this end, themsysgit projectis rapidly putting together a solution includingvarious packages with full installers. These include GitMe, a package to install the entiredevelopment environment necessary to work on improving the msysgit port of git, and WinGit,a package for installing just git itself without the development environment, (still in Alpha as of September 2007).
2.2 Getting started
To begin, we’ll use the “git version” command to find out whether git is actually installedproperly. Versions 1.5 and newer of git are much more friendly to new users than versions 1.4and older. If you aren't yet running version 1.5 or newer, it's highly recommended that youupgrade.
$ git versiongit version 1.5.3.2
2.2.1 Built-in help
Git provides a built-in help system. This is invaluable for those times when you find yourself stuck trying to remember how to run a command. If you are completely stuck, simply run “githelp”; it will print a brief list of commonly-used commands, along with a description of what
A tour of git: the basicshttp://cworth.org/hgbook-git/tour/2 of 234/11/08 7:21 PM
 
each does. If you ask for help on a specific command (such as "git help init"), it prints moredetailed information. [XXX: Does
git help <foo>
work universally as a built-in or does it expectman to be present and just call out to
man git-<foo>
?]
[XXX: The original hgbook includes the complete output of "hghelp init" at this point. I'm not including the corresponding"git help init" output as it would be excessively long. Thedescription alone is quite reasonable, (other than anot-too-helpful aside about the obsolete git-init-db command),but it only comes after a full screen's worth of optionsdetails. Might it make sense to have a more summarized helpoutput for "git help <foo>" than all of the documentationavailable for git-<foo>? And perhaps alos provide a "git -vhelp" similar to "hg -v help" for more?]
2.3 Working with a repository
In git, everything happens inside a repository. The repository for a project contains all of thefiles that “belong to” that project, along with a historical record of the project’s files.There’s nothing particularly magical about a repository; it is simply a directory tree in yourfilesystem that git treats as special. You can rename or delete a repository any time you like,using either the command line or your file browser.
2.3.1 Creating a copy of a remote repository
The "git clone" command is used to create a local copy of a remote repository. This is generallythe first git operation you will use when beginning to work with an existing project.We've assembled a simple repository that will be used in the examples throughout this chapter.Go ahead and clone this repository now so that you will be able to follow along:
$ git clone git://cworth.org/git/helloInitialized empty Git repository in /tmp/hello/.git/remote: Generating pack...remote: Done counting 15 objects.remote: Deltifying 15 objects...remote: 100% (15/15) doneremote: Total 15 (delta 2), reused 15 (delta remote: 2)Indexing 15 objects...100% (15/15) doneResolving 2 deltas...100% (2/2) done
If for some reason you are prevented from talking on the git: port, then there is also thecapability to clone a repository (less efficiently) over http:
$ git clone http://cworth.org/git/helloInitialized empty Git repository in /tmp/hello/.git/Getting alternates list for http://cworth.org/git/helloGetting pack list for http://cworth.org/git/helloGetting index for pack 04ecb061314ecbd60fa0610ecf55a1cbf85ea294Getting pack 04ecb061314ecbd60fa0610ecf55a1cbf85ea294which contains a1a0e8b392b17caf50325498df54802fe3c03710
A tour of git: the basicshttp://cworth.org/hgbook-git/tour/3 of 234/11/08 7:21 PM

Activity (7)

You've already reviewed this. Edit your review.
1 hundred reads
1 thousand reads
yjlee123 liked this
jobinjames liked this
gccusr liked this
MrBlueSky1 liked this
Chuck Jordan liked this

You're Reading a Free Preview

Download
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->