installation and reference manual

GIT installation, quick reference manual and usage
fabiodelorenzo
Posts: 65
Joined: Thu Oct 03, 2013 5:54 pm

installation and reference manual

Postby fabiodelorenzo » Thu Oct 03, 2013 8:32 pm

from http://progit.org/book/

* Installation:

binaries:
yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
yum install git-core

apt-get install libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev
apt-get install git-core


source:
http://git-scm.com/download

$ tar -zxf git-1.7.2.2.tar.gz
$ cd git-1.7.2.2
$ make prefix=/usr/local all
$ sudo make prefix=/usr/local install


* First-Time Git Setup

remember you can use --system OR --global

--system => /etc/gitconfig file
Contains values for every user on the system and all their repositories.


--global option => ~/.gitconfig file
Specific to your user home directory
if you do so, you also have to do :
git config --global user.name "John Doe"
git config --global user.email johndoe@example.com

configure GIT to use vimdiff for the diffing:
git config --global merge.tool vimdiff

Checking Your Settings
git config --list

* Initializing a Repository importing data from an Existing Directory
cd _project_directory_
git init
git add *.c # including all the .c files
git add README # including some other file
git commit -m 'initial project version'

* Cloning an Existing Repository (get a copy of an existing Git repository)
git clone git://git_url/myproject.git
If you want to clone the repository into a directory named something other than myproject:
git clone ggit://git_url/myproject.git mylocalproject


* Checking the Status of Your Files
git status
# On branch master
nothing to commit (working directory clean)

* Adding New Files or STAGING an existing one
git add README

* Ignoring Files
.gitignore
*.[oa] # ignore any files ending in .o or .a
*~ # ignore all files that end with a tilde (~)

* Viewing Your Staged and Unstaged Changes
git status
git diff # diff working and staged repos
git diff --cached # diff staged and committed repos

* Committing Your Changes
git commit # vi manual interaction for comment
git commit -m "Story 182: Fix benchmarks for speed" #comment in line


* Removing Files
rm grit.gemspec
git status
git rm grit.gemspec

Note the back slashes: git rm log/\*.log ..and.. git rm \*~

# keep the file in your working tree but remove it from your staging area
git rm --cached readme.txt

* Moving Files
git mv file_from file_to
is equivalent to:
mv README.txt README
git rm README.txt
git add README

* Viewing the Commit History
git log
One of the more helpful options is -p, which shows the diff introduced in each commit.
You can also use -2, which limits the output to only the last two entries:
git log -p -2

Return to “Git”

Who is online

Users browsing this forum: No registered users and 0 guests