Git, Beginner to Advanced Survey

Embed Size (px)

Text of Git, Beginner to Advanced Survey

Prezentacja nowego produktu

GIT, Beginner to Advanced Survey

Rafa RusinTouKhttp://touk.plhttp://rrusin.blogspot.com

What is GIT?

Global Information Tracker when it works
"goddamn idiotic truckload of sh*t": when it breaks

Distributed Version Control System
Unlike SVN, which is centralized

Designed for speed
git log, git checkout , git blame are done locally

Designed for branching and merging
Includes tuned 3 way merge algorithm for resolving conflicts,
with handling merges including file renames.

Works on data, not on file names (hashes)

GIT has Distributed Model

Centralized & Distributed model

asasdf

Getting Started

Configuring GIT
Create a file ~/.gitconfig and set up user name and email this info may be distributed globally

Initialize repositorygit init

Open GUIgit gui

Stage files for commit and create a commitCommit is stored locally

Connecting to External World

Cloning remote repositorygit clone git@github.com:rafalrusin/ode-scripts.git (example)There is support for protocols, like ssh and file:git clone ../other-dir, git clone ssh://user@host/full-path-to-project

Create local commits

Push to remote repositorygit gui / remote / pushNote: It may fail due to not merged newest remote commits. You will need to do fetch, merge and push again.

Working with Branches

GIT is usable for maintaining forksMerging to latest upstream release is easy

Creating a branch from current HEADgit checkout -b NAME

Merging other branch into HEADgit merge NAMEIf a confict occurs, use git mergetool (like meld)

Rebasing a set of commits onto other headgit rebase onto OTHER_HEAD

Advanced Commands

Git cherry-pick merge single commit into current HEAD

Git stash store local changes to work on other branch

Amend last commit update last commit by new changeset

Git grep lookup data over indexed files only

Git blame provides author and revision for each line of file

Git submodules similar to svn:externals, adds possibility of joining different projects into one
http://speirs.org/blog/2009/5/11/understanding-git-submodules.html

Git apply index - applies a patch and stages it in index

Git show - show a diff for commit

Git reset hard, git checkout-index -f - drop local changes

Publishing Code With GitWeb

Bare repositoriesgit clone bare - creates repository without working copy

SSH repositories ssh://user@server/full-path-to-repo

Native GIT repositories (eg. via gitosis)git@server.com:path/repo.git

Configuring project descriptiondescription, README.html, config [gitweb] owner, URL

Integrating With Hudson

Hudson Continous Integration
has GIT support

CI builds using GIT have advantageYou can set up Hudson to build multiple branches. Then developers may submit their forked branch to see if they work passes tests. Then if it's OK, they can merge to master. This way you won't have unstable commits in master branch.

References

Running GIT under Windows (msysgit)
http://nathanj.github.com/gitguide/index.html - also explains features of git gui

GitHub social coding

git.apache.org, github.com/apache

Tools - git-scm.com

Who uses GIT?Android, Jquery, digg.com, linux kernel, Qt, YUIhttp://en.wikipedia.org/wiki/Git_%28software%29#Projects_using_Git