36
Let's GIT to it! Introduction to GIT Yoram Michaeli <[email protected]> December 2013

Lets git to it

Embed Size (px)

Citation preview

Page 1: Lets git to it

Let's GIT to it!

Introduction to GITYoram Michaeli <[email protected]>

December 2013

Page 2: Lets git to it

Before you GIT it...

Page 3: Lets git to it

What is GIT?

Page 4: Lets git to it

What is GIT?

● GIT is a distributed revision controland source code management system(DVCS)

● GIT were created, designed and developed by Linus Torvalds (the creator of Linux) for Linux kernel development.(See Linus Torvalds in YouTube )

● Official GIT site: http://git-scm.com

Page 5: Lets git to it

Why use GIT?

Page 6: Lets git to it

Why use GIT?There are many other SCM/SVCS systems out there...

GIT is fast

GIT has no need for network connection - for most operations

GIT is a great merge and branching tool

GIT is a modern tool

GIT have a very large install-base

GIT encourage developers to commit, which results with less data loose

Page 7: Lets git to it

GIT is distributed

● There is no single server – each endpoint contains all the information.

● Usually there is one endpoint that is considered as the central one but this is not a must.

● The common flow:● You clone the central repository and sync with its

content● You work offline on your private repository● You push your local changes into the central

repository

Page 8: Lets git to it

GIT is distributed

Page 9: Lets git to it

GIT is fast

● For most operation you don't need network connection

● Network operations are done very fast using modern and validated transfer actions

● GIT uses snapshots of the whole repository instead of the files-and-delta technology

● GIT uses pointers● GIT is optimized for merge...

Page 10: Lets git to it

GIT is optimized for merge

● GIT is designed for fast and efficient merge● GIT supports:

● Local merge● 2 repositories/endpoints merge● Simultaneously work on the same resource

● Merge is usually done locally before pushing it to the remote repository so it is very easy to abort it or revert to the previous status

Page 11: Lets git to it

Things you must consider about GIT

Page 12: Lets git to it

Things you must consider about GIT

● GIT requires you to understand it for using it● GIT is not CVS or SVN or any of those tools● GIT requires much to learn about it● GIT command line interface (CLI) is the most

recommended client for it

Page 13: Lets git to it

GIT concepts overview

Page 14: Lets git to it

SVN/CVS vs. GIT

Page 15: Lets git to it

GIT commit representation

Page 16: Lets git to it

GIT repository – the multiple commit concept

Each commit store a pointer to the former (checksum) commit The first commit has a null pointer

Page 17: Lets git to it

GIT branches – basic terms

branch – a pointer to some commitmaster – the “default” branchHEAD – the current branch of the local/remote repositoryorigin – the remote repository (usually – the one you have cloned from)origin/master – the master branch (pointer) of the origin repository

Page 18: Lets git to it

GIT local workGIT directoryis where Git stores the metadata and object database for your project

Working directoryis a single checkout of one version of the project on your disk.

Staging area (Index)is a simple snapshot file in your Git directory, that stores information about what will go into your next commit.

Why staging?Gives you the ability to control the content of your next commitYou can reset changesYou can 'stash' all changes and work on a new task in the same locationOnce your done with your code – for committing - you can:

Review the differences between working directory and stagingReview the differences between staging and HEAD

Page 19: Lets git to it

A GIT file life-cycle

Page 20: Lets git to it

GIT basic flow and operations

Page 21: Lets git to it

The common flow:● You clone the central repository and sync with its content:

– Method 1:

> git pull

– Method 2:

> git fetch > git rebase

● You work offline on your private repository

> git add --all > git commit -m “<comment>”

● You push your local changes into the central repository

> git push origin master

GIT basic flow

Page 22: Lets git to it

GIT common actions & flow

Page 23: Lets git to it

● git clone – clone a repository into a new copy● git status – show the status of your local repository

git log – show commit logs

git diff - show the differences between anything: states, branches and more

git branch – perform branch-related actions such as create branch, list branches and more

git checkout – switch to work on a certain snapshot (branch, hash, tag)

git merge – merge into current working snapshot

git cherrypick – merge picked commits from branch to branch

Other GIT common commands

Page 24: Lets git to it

Let's GIT startedInstall GIT (usually from http://git-scm.com/)Initial global settings

> git config --global user.name “Bill Gates”

> git config --global user.email “[email protected]

> git config --global color.ui true

git init > mkdir microsoft

> cd microsoft

> git init

or git clone > cd Microsoft

> git clone git@microsoft:acquired-companies/someTool.git

Page 25: Lets git to it

GIT tools

Page 26: Lets git to it

GIT hosting tools and services

Page 27: Lets git to it

GIT cloud-based hosting services

https://git.wiki.kernel.org/index.php/GitHosting

Page 28: Lets git to it

GIT on-premise hosting tools

http://en.wikipedia.org/wiki/Comparison_of_free_software_hosting_facilities

Page 29: Lets git to it

Detailed guideline for choosing GIT host service

http://www.slideshare.net/YoramMichaeli/git-hostingservice

Page 30: Lets git to it

GIT client tools

Page 31: Lets git to it

GIT GUI client tools

https://git.wiki.kernel.org/index.php/InterfacesFrontendsAndTools

SourceTree

GitHub

GitX

Gitg

SmartGit

Page 32: Lets git to it

GIT branching model

Page 33: Lets git to it

GIT branching modelbased on http://nvie.com/posts/a-successful-git-branching-model

Page 34: Lets git to it

GIT more

Page 36: Lets git to it