44
Git Kornel Lugosi @Coornail May 17, 2011

Git introduction

Embed Size (px)

DESCRIPTION

I was presenting an introduction to Git at Szegedtech

Citation preview

Page 1: Git introduction

Git

Kornel Lugosi@Coornail

May 17, 2011

Page 2: Git introduction

Table of contentsVersion control

Distributed revision control

Repository

Adding, commiting

Tracking changes

Branches

Pushing, pulling

Submodules

Ranges and other identifications of hashes

Other fun stuff

Resources

Page 3: Git introduction

Version control

What?

Page 4: Git introduction

Version control

Why?

Page 5: Git introduction

Version control

Why?

◮ Backup

Page 6: Git introduction

Version control

Why?

◮ Backup

◮ Revision handling

Page 7: Git introduction

Version control

Why?

◮ Backup

◮ Revision handling

◮ Teamwork

Page 8: Git introduction

Version control

Why?

◮ Backup

◮ Revision handling

◮ Teamwork

◮ Organized code commit access and workflow

Page 9: Git introduction

Version control

Why?

◮ Backup

◮ Revision handling

◮ Teamwork

◮ Organized code commit access and workflow

◮ Deploying

Page 10: Git introduction

Version control

How?

Page 11: Git introduction

Version control

How?

◮ CVS

Page 12: Git introduction

Version control

How?

◮ CVS

◮ SVN

Page 13: Git introduction

Version control

How?

◮ CVS

◮ SVN

◮ Hg(Mercurial)

Page 14: Git introduction

Version control

How?

◮ CVS

◮ SVN

◮ Hg(Mercurial)

◮ bzr (Bazaar)

Page 15: Git introduction

Version control

How?

◮ CVS

◮ SVN

◮ Hg(Mercurial)

◮ bzr (Bazaar)

◮ ...

Page 16: Git introduction

Version control

How?

◮ CVS

◮ SVN

◮ Hg(Mercurial)

◮ bzr (Bazaar)

◮ ...

◮ Git

Page 17: Git introduction

Distributed revisioncontrol

Page 18: Git introduction

Repository

(Repo)

Page 19: Git introduction

Repository

$ git init

Page 20: Git introduction

Repository

$ git init

$ git init --bare

Page 21: Git introduction

Repository

$ git init

$ git init --bare

$ git init --bare --shared=group

Page 22: Git introduction

Let’s put some code in!

$ echo "some code" > index.php$ git add index.php

Page 23: Git introduction

Let’s put some code in!

$ echo "some code" > index.php$ git add index.php

Oh shit, it is only added to the “index“!

Page 24: Git introduction

Let’s put some code in!

$ echo "some code" > index.php$ git add index.php

Oh shit, it is only added to the “index“!Well, fuck that!

$ git commit -m "My first commit"

Page 25: Git introduction

Let’s put some code in!

$ echo "some code" > index.php$ git add index.php

Oh shit, it is only added to the “index“!Well, fuck that!

$ git commit -m "My first commit"

But it is not on the remote server yet!

$ git push ...

Page 26: Git introduction

Nobody is looking, let’s commiteverything!

$ cat > index.php<?php

Thousand lines of code...ˆD$ git commit -a

Page 27: Git introduction

What the hell did I do?

(in the working tree)$ git diff

Page 28: Git introduction

What the hell did I do a year ago?

$ git log

Page 29: Git introduction

I have no idea what I do

Let’s not show it toeveryone (yet)!

$ git branch experimental$ git checkout experimental

Page 30: Git introduction

What branch am I on?

$ git branch -a

Page 31: Git introduction

Turns out I am smart after all

$ git checkout master$ git merge experimental

Page 32: Git introduction

I was smart today

Let’s show it to everyone$ git push <repository> <refspec>

Page 33: Git introduction

I was smart today

Let’s show it to everyone$ git push <repository> <refspec>

Damn! Somebody was faster...Conflict =(

Page 34: Git introduction

My code, let me show it to you!

$ git clone <repository>

Page 35: Git introduction

My code, let me show it to you!

$ git clone <repository>

Okay, I already have you repo, I want to laugh atyour code!

boss$ git pull <repository>

Page 36: Git introduction

Tagging

$ git tag

Page 37: Git introduction

Submodules

Page 38: Git introduction

Submodules

$ git submodule add <repository><path>

Page 39: Git introduction

Submodules

$ git submodule add <repository><path>

From the root directory!

Page 40: Git introduction

Ranges

$ git log 0af56ffa..HEAD

Page 41: Git introduction

Ranges

$ git log 0af56ffa..HEAD

$ git diff v2.5..HEADˆ

Page 42: Git introduction

Ranges

$ git log 0af56ffa..HEAD

$ git diff v2.5..HEADˆ

$ git cherry-pick HEAD˜4..

Page 43: Git introduction

Other fun stuff

◮ $ git revert◮ $ git reset◮ $ git stash◮ $ git bisect◮ $ git rebase◮ $ git gc