223
Yet Another GIT Tutorial by Giso H. Dal Version 2.2

Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

  • Upload
    others

  • View
    26

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet Another GIT Tutorial

by Giso H. Dal

Version 2.2

Page 2: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Outline

1 Introduction

2 ArchitectureCVCS vs DVCSSVN vs GIT

3 CommandsLocal RepositoryRemote Repository

4 Workflow

5 Tips and Tricks

Page 3: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Outline

1 Introduction

2 ArchitectureCVCS vs DVCSSVN vs GIT

3 CommandsLocal RepositoryRemote Repository

4 Workflow

5 Tips and Tricks

Page 4: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Why version control?

For the individual, have you ever:Made a change to your code, realised it was a mistake and wanted torevert back?Lost code or had a backup that was too old?Had to maintain multiple versions of a product?Wanted to see the difference between multiple versions of your code?Wanted to experiment with a new feature without interfering withworking code?Wanted to synchronize your work across multiple devices?

For the group, have you ever:Wanted to work together on the same project on the same file, at thesame time?Wanted to share your code, or let other people work on your code?Wanted to see how much work is being done, where, when and bywhom?

Page 5: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Outline

1 Introduction

2 ArchitectureCVCS vs DVCSSVN vs GIT

3 CommandsLocal RepositoryRemote Repository

4 Workflow

5 Tips and Tricks

Page 6: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Centralized Version Control

Client-ServerPeer-to-Peer

Server

Bob Phil Amy

Page 7: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Centralized Version Control

Client-ServerPeer-to-Peer

Server

Bob Phil Amy

Page 8: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Centralized Version Control

Client-ServerPeer-to-Peer

Server

Bob Phil Amy

Page 9: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Centralized Version Control

Client-ServerPeer-to-Peer

Server

Bob Phil Amy

Page 10: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Centralized Version Control

Client-ServerPeer-to-Peer

Server

Bob Phil Amy

Page 11: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Centralized Version Control

Client-ServerPeer-to-Peer

Server

Bob Phil Amy

Page 12: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Centralized Version Control

Client-Server

Peer-to-Peer

Server

Bob Phil Amy

Page 13: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Distributed Version Control

Client-ServerPeer-to-Peer

Server

Bob Phil Amy

Page 14: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Distributed Version Control

Client-ServerPeer-to-Peer

Server

Bob Phil Amy

Page 15: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Distributed Version Control

Client-ServerPeer-to-Peer

Server

Bob Phil Amy

Page 16: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Distributed Version Control

Client-ServerPeer-to-Peer

Server

Bob Phil Amy

Page 17: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Distributed Version Control

Client-ServerPeer-to-Peer

Server

Bob Phil Amy

Page 18: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Distributed Version Control

Client-ServerPeer-to-Peer

Server

Bob Phil Amy

Page 19: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Distributed Version Control

Client-ServerPeer-to-Peer

Server

Bob Phil Amy

Page 20: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Distributed Version Control

Client-ServerPeer-to-Peer

Server

Bob Phil Amy

Page 21: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Distributed Version Control

Client-ServerPeer-to-Peer

Server

Bob Phil Amy

Page 22: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Distributed Version Control

Client-Server

Peer-to-Peer

Server

Bob Phil Amy

Page 23: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Subversion vs GIT

Subversion GIT

Repository Model Client-Server DistributedDevelopment Active ActiveRevision IDs Numbers SHA-1 HashesBranching/Merging Hard; Directory Easy; SnapshotPartial Checkout Yes NoSupported Formats subversion git, cvs, subversion,

hg, any that has a fas-texporter

Support Large Files Yes NoPerformance Slow FastBisect Third party YesFile Locking Yes NoWork Offline No YesCreate Repository Only admin Any userReliablility Reasonable VeryRepository size Reasonable SmallMerge type Implicit Explicit

Page 24: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Subversion Workflow

Commit

Bobfile1 file2 file3

Commit

Philfile1 file2 file3

CommitUpdateMerge

Amy

file1 file2 file3

Tim

e

3

4

1

2 3 4

5

6

Page 25: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Subversion Workflow

Commit

Bob

1

file1

1

file2

1

file3

Commit

Phil

1

file1

1

file2

1

file3

CommitUpdateMerge

Amy

1

file1

1

file2

1

file3

Tim

e

3

4

1

2 3 4

5

6

Page 26: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Subversion Workflow

Commit

Bob

1

file1

1

file2

1

file3

Commit

Phil

1

file1

1

file2

1

file3

CommitUpdateMerge

Amy

1

file1

1

file2

1

file3

Tim

e

3

4

1

2 3 4

5

6

Page 27: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Subversion Workflow

Commit

Bob

2

file1

1

file2

1

file3

Commit

Phil

1

file1

1

file2

1

file3

CommitUpdateMerge

Amy

1

file1

1

file2

1

file3

Tim

e

3

4

1

2

3 4

5

6

Page 28: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Subversion Workflow

Commit

Bob

2

file1

1

file2

1

file3

Commit

Phil

1

file1

1

file2

1

file3

CommitUpdateMerge

Amy

1

file1

1

file2

1

file3

Tim

e

3

4

1

2

3 4

5

6

Page 29: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Subversion Workflow

Commit

Bob

2

file1

1

file2

1

file3

Commit

Phil

1

file1

3

file2

1

file3

CommitUpdateMerge

Amy

1

file1

1

file2

1

file3

Tim

e

3

4

1

2

3 4

5

6

Page 30: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Subversion Workflow

Commit

Bob

2

file1

1

file2

1

file3

Commit

Phil

1

file1

3

file2

1

file3

Commit

UpdateMerge

Amy

1

file1

1

file2

1

file3

Tim

e

3

4

1

2

3 4

5

6

Page 31: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Subversion Workflow

Commit

Bob

2

file1

1

file2

1

file3

Commit

Phil

1

file1

3

file2

1

file3

CommitUpdateMerge

Amy

1

file1

1

file2

4

file3

Tim

e

3

4

1

2

3 4

5

6

Page 32: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Subversion Workflow

Commit

Bob

2

file1

1

file2

1

file3

Commit

Phil

1

file1

3

file2

1

file3

Commit

Update

Merge

Amy

1

file1

1

file2

4

file3

Tim

e

3

4

1

2

3 4

5

6

Page 33: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Subversion Workflow

Commit

Bob

2

file1

1

file2

1

file3

Commit

Phil

1

file1

3

file2

1

file3

CommitUpdateMerge

Amy

2

file1

3

file2

4

file3

Tim

e

3

4

1

2

3 4

5

6

Page 34: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

GIT Workflow

Commit

Bob

1

file1

1

file2

1

file3

Commit

Phil

1

file1

1

file2

1

file3

CommitUpdateMerge

Amy

1

file1

1

file2

1

file3

Tim

e

3

4

1

2 3 4

5

6

Page 35: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

GIT Workflow

Commit

Bob

1

file1

1

file2

1

file3

Commit

Phil

1

file1

1

file2

1

file3

Commit

UpdateMerge

Amy

1

file1

1

file2

1

file3

Tim

e

3

4

1

2 3 4

5

6

Page 36: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

GIT Workflow

Commit

Bob

2

file1

2

file2

2

file3

Commit

Phil

3

file1

3

file2

3

file3

CommitUpdate

Merge

Amy

4

file1

4

file2

4

file3

Tim

e

3

4

1

2 3 4

5

6

Page 37: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

GIT Workflow

Commit

Bob

2

file1

2

file2

2

file3

Commit

Phil

3

file1

3

file2

3

file3

CommitUpdate

Merge

Amy

5

file1

5

file2

5

file3

Tim

e

3

4

1

2 3 4

5

6

Page 38: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

GIT Workflow

Commit

Bob

2

file1

2

file2

2

file3

Commit

Phil

3

file1

3

file2

3

file3

CommitUpdateMerge

Amy

6

file1

6

file2

6

file3

Tim

e

3

4

1

2 3 4

5

6

Page 39: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Outline

1 Introduction

2 ArchitectureCVCS vs DVCSSVN vs GIT

3 CommandsLocal RepositoryRemote Repository

4 Workflow

5 Tips and Tricks

Page 40: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

The Commands: GIT Architecture

Local Remote

init

add

commit

statuslog

diff

checkout

branchmerge

revert

reset

remote

branch -u

clonepush

fetchpull

Workspace Staging Index+Repo Repo

Page 41: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

The Commands

Local repository

Creating local repositoryUsing version control

Remote repository

Creating and connecting to remote repositorySetup server without root priviledges

Page 42: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Local Repository

1 Committing

2 Status

3 Branching

4 Merging

5 Revert, Reset and Delete

Page 43: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Committing

1 Committing

2 Status

3 Branching

4 Merging

5 Revert, Reset and Delete

Page 44: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Committing

Local Remote

init

add

commit

statuslog

diff

checkout

branchmerge

revert

reset

remote

branch -u

clonepush

fetchpull

Workspace Staging Index+Repo Repo

Page 45: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Committing

>

echo ’hello 1’ > file1>

echo ’hello 2’ > file2

>

git init

>

git add .

>

git commit -m ’initial’

>

echo ’hello 3’ >> file2

>

git add .

>

git commit -m ’updated file2’

>

Local Repository

1 2

3 4

5 6

7

Index

file1 file2 file3

Staging Area

file1 file2 file3

Workspace

file1

hello 1hello 5

file2

hello 2

file3hello 4

hello 7

Page 46: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Committing

> echo ’hello 1’ > file1

>

echo ’hello 2’ > file2

>

git init

>

git add .

>

git commit -m ’initial’

>

echo ’hello 3’ >> file2

>

git add .

>

git commit -m ’updated file2’

>

Local Repository

1 2

3 4

5 6

7

Index

file1 file2 file3

Staging Area

file1 file2 file3

Workspace

file1

hello 1hello 5

file2

hello 2

file3hello 4

hello 7

Page 47: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Committing

> echo ’hello 1’ > file1>

echo ’hello 2’ > file2>

git init

>

git add .

>

git commit -m ’initial’

>

echo ’hello 3’ >> file2

>

git add .

>

git commit -m ’updated file2’

>

Local Repository

1 2

3 4

5 6

7

Index

file1 file2 file3

Staging Area

file1 file2 file3

Workspace

file1hello 1

hello 5

file2

hello 2

file3hello 4

hello 7

Page 48: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Committing

> echo ’hello 1’ > file1> echo ’hello 2’ > file2

>

git init

>

git add .

>

git commit -m ’initial’

>

echo ’hello 3’ >> file2

>

git add .

>

git commit -m ’updated file2’

>

Local Repository

1 2

3 4

5 6

7

Index

file1 file2 file3

Staging Area

file1 file2 file3

Workspace

file1hello 1

hello 5

file2

hello 2

file3hello 4

hello 7

Page 49: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Committing

> echo ’hello 1’ > file1> echo ’hello 2’ > file2>

git init>

git add .

>

git commit -m ’initial’

>

echo ’hello 3’ >> file2

>

git add .

>

git commit -m ’updated file2’

>

Local Repository

1 2

3 4

5 6

7

Index

file1 file2 file3

Staging Area

file1 file2 file3

Workspace

file1hello 1

hello 5

file2hello 2

file3hello 4

hello 7

Page 50: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Committing

> echo ’hello 1’ > file1> echo ’hello 2’ > file2> git init

>

git add .

>

git commit -m ’initial’

>

echo ’hello 3’ >> file2

>

git add .

>

git commit -m ’updated file2’

>

Local Repository

1 2

3 4

5 6

7

Index

file1 file2 file3

Staging Area

file1 file2 file3

Workspace

file1hello 1

hello 5

file2hello 2

file3hello 4

hello 7

Page 51: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Committing

> echo ’hello 1’ > file1> echo ’hello 2’ > file2> git init>

git add .>

git commit -m ’initial’

>

echo ’hello 3’ >> file2

>

git add .

>

git commit -m ’updated file2’

>

Local Repository

1 2

3 4

5 6

7

Index

file1 file2 file3

Staging Area

file1 file2 file3

Workspace

file1hello 1

hello 5

file2hello 2

file3hello 4

hello 7

Page 52: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Committing

> echo ’hello 1’ > file1> echo ’hello 2’ > file2> git init> git add .

>

git commit -m ’initial’

>

echo ’hello 3’ >> file2

>

git add .

>

git commit -m ’updated file2’

>

Local Repository

1 2

3 4

5 6

7

Index

file1 file2 file3

Staging Area

file1 file2 file3

Workspace

file1hello 1

hello 5

file2hello 2

file3hello 4

hello 7

Page 53: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Committing

> echo ’hello 1’ > file1> echo ’hello 2’ > file2> git init> git add .>

git commit -m ’initial’>

echo ’hello 3’ >> file2

>

git add .

>

git commit -m ’updated file2’

>

Local Repository

1 2

3 4

5 6

7

Indexfile1 file2

file3

Staging Area

file1 file2 file3

Workspace

file1hello 1

hello 5

file2hello 2

file3hello 4

hello 7

Page 54: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Committing

> echo ’hello 1’ > file1> echo ’hello 2’ > file2> git init> git add .> git commit -m ’initial’

>

echo ’hello 3’ >> file2

>

git add .

>

git commit -m ’updated file2’

>

Local Repository

1 2

3 4

5 6

7

Indexfile1 file2

file3

Staging Area

file1 file2 file3

Workspace

file1hello 1

hello 5

file2hello 2

file3hello 4

hello 7

Page 55: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Committing

> echo ’hello 1’ > file1> echo ’hello 2’ > file2> git init> git add .> git commit -m ’initial’>

echo ’hello 3’ >> file2>

git add .

>

git commit -m ’updated file2’

>

master

Local Repository

1

2

3 4

5 6

7

Index

file1 file2 file3

Staging Areafile1 file2

file3

Workspace

file1hello 1

hello 5

file2hello 2

file3hello 4

hello 7

Page 56: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Committing

> echo ’hello 1’ > file1> echo ’hello 2’ > file2> git init> git add .> git commit -m ’initial’> echo ’hello 3’ >> file2

>

git add .

>

git commit -m ’updated file2’

>

master

Local Repository

1

2

3 4

5 6

7

Index

file1 file2 file3

Staging Areafile1 file2

file3

Workspace

file1hello 1

hello 5

file2hello 2

file3hello 4

hello 7

Page 57: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Committing

> echo ’hello 1’ > file1> echo ’hello 2’ > file2> git init> git add .> git commit -m ’initial’> echo ’hello 3’ >> file2>

git add .>

git commit -m ’updated file2’

>

master

Local Repository

1

2

3 4

5 6

7

Index

file1 file2 file3

Staging Areafile1 file2

file3

Workspace

file1hello 1

hello 5

file2hello 2hello 3

file3hello 4

hello 7

Page 58: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Committing

> echo ’hello 1’ > file1> echo ’hello 2’ > file2> git init> git add .> git commit -m ’initial’> echo ’hello 3’ >> file2> git add .

>

git commit -m ’updated file2’

>

master

Local Repository

1

2

3 4

5 6

7

Index

file1 file2 file3

Staging Areafile1 file2

file3

Workspace

file1hello 1

hello 5

file2hello 2hello 3

file3hello 4

hello 7

Page 59: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Committing

> echo ’hello 1’ > file1> echo ’hello 2’ > file2> git init> git add .> git commit -m ’initial’> echo ’hello 3’ >> file2> git add .>

git commit -m ’updated file2’>

master

Local Repository

1

2

3 4

5 6

7

Indexfile1 file2

file3

Staging Areafile1 file2

file3

Workspace

file1hello 1

hello 5

file2hello 2hello 3

file3hello 4

hello 7

Page 60: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Committing

> echo ’hello 1’ > file1> echo ’hello 2’ > file2> git init> git add .> git commit -m ’initial’> echo ’hello 3’ >> file2> git add .> git commit -m ’updated file2’

>

master

Local Repository

1

2

3 4

5 6

7

Indexfile1 file2

file3

Staging Areafile1 file2

file3

Workspace

file1hello 1

hello 5

file2hello 2hello 3

file3hello 4

hello 7

Page 61: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Committing

> echo ’hello 1’ > file1> echo ’hello 2’ > file2> git init> git add .> git commit -m ’initial’> echo ’hello 3’ >> file2> git add .> git commit -m ’updated file2’>

master

Local Repository

1 2

3 4

5 6

7

Index

file1 file2 file3

Staging Areafile1 file2

file3

Workspace

file1hello 1

hello 5

file2hello 2hello 3

file3hello 4

hello 7

Page 62: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Status

1 Committing

2 Status

3 Branching

4 Merging

5 Revert, Reset and Delete

Page 63: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Status

Local Remote

init

add

commit

statuslog

diff

checkout

branchmerge

revert

reset

remote

branch -u

clonepush

fetchpull

Workspace Staging Index+Repo Repo

Page 64: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Status

>

echo ’hello 4’ > file3>

echo ’hello 5’ >> file1

>

git status

# On branch master

# Changes not staged.. :

# modified: file1

#

# Untracked files:

# file3

>

git log

commit 2

Author: Its Me

Date: Feb 6 15:21:38 2014

updated file2

...

>

git diff file1

diff --git a/file1 b/file1

hello 1

+hello 5

>

master

Local Repository

1 2

3 4

5 6

7

Index

file1 file2 file3

Staging Areafile1 file2

file3

Workspace

file1hello 1

hello 5

file2hello 2hello 3

file3hello 4

hello 7

Page 65: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Status

> echo ’hello 4’ > file3

>

echo ’hello 5’ >> file1

>

git status

# On branch master

# Changes not staged.. :

# modified: file1

#

# Untracked files:

# file3

>

git log

commit 2

Author: Its Me

Date: Feb 6 15:21:38 2014

updated file2

...

>

git diff file1

diff --git a/file1 b/file1

hello 1

+hello 5

>

master

Local Repository

1 2

3 4

5 6

7

Index

file1 file2 file3

Staging Areafile1 file2

file3

Workspace

file1hello 1

hello 5

file2hello 2hello 3

file3hello 4

hello 7

Page 66: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Status

> echo ’hello 4’ > file3>

echo ’hello 5’ >> file1>

git status

# On branch master

# Changes not staged.. :

# modified: file1

#

# Untracked files:

# file3

>

git log

commit 2

Author: Its Me

Date: Feb 6 15:21:38 2014

updated file2

...

>

git diff file1

diff --git a/file1 b/file1

hello 1

+hello 5

>

master

Local Repository

1 2

3 4

5 6

7

Index

file1 file2 file3

Staging Areafile1 file2

file3

Workspace

file1hello 1

hello 5

file2hello 2hello 3

file3hello 4

hello 7

Page 67: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Status

> echo ’hello 4’ > file3> echo ’hello 5’ >> file1

>

git status

# On branch master

# Changes not staged.. :

# modified: file1

#

# Untracked files:

# file3

>

git log

commit 2

Author: Its Me

Date: Feb 6 15:21:38 2014

updated file2

...

>

git diff file1

diff --git a/file1 b/file1

hello 1

+hello 5

>

master

Local Repository

1 2

3 4

5 6

7

Index

file1 file2 file3

Staging Areafile1 file2

file3

Workspace

file1hello 1

hello 5

file2hello 2hello 3

file3hello 4

hello 7

Page 68: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Status

> echo ’hello 4’ > file3> echo ’hello 5’ >> file1>

git status# On branch master

# Changes not staged.. :

# modified: file1

#

# Untracked files:

# file3

>

git log

commit 2

Author: Its Me

Date: Feb 6 15:21:38 2014

updated file2

...

>

git diff file1

diff --git a/file1 b/file1

hello 1

+hello 5

>

master

Local Repository

1 2

3 4

5 6

7

Index

file1 file2 file3

Staging Areafile1 file2

file3

Workspace

file1hello 1hello 5

file2hello 2hello 3

file3hello 4

hello 7

Page 69: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Status

> echo ’hello 4’ > file3> echo ’hello 5’ >> file1> git status

# On branch master

# Changes not staged.. :

# modified: file1

#

# Untracked files:

# file3

>

git log

commit 2

Author: Its Me

Date: Feb 6 15:21:38 2014

updated file2

...

>

git diff file1

diff --git a/file1 b/file1

hello 1

+hello 5

>

master

Local Repository

1 2

3 4

5 6

7

Index

file1 file2 file3

Staging Areafile1 file2

file3

Workspace

file1hello 1hello 5

file2hello 2hello 3

file3hello 4

hello 7

Page 70: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Status

> echo ’hello 4’ > file3> echo ’hello 5’ >> file1> git status

# On branch master

# Changes not staged.. :

# modified: file1

#

# Untracked files:

# file3

>

git logcommit 2

Author: Its Me

Date: Feb 6 15:21:38 2014

updated file2

...

>

git diff file1

diff --git a/file1 b/file1

hello 1

+hello 5

>

master

Local Repository

1 2

3 4

5 6

7

Index

file1 file2 file3

Staging Areafile1 file2

file3

Workspace

file1hello 1hello 5

file2hello 2hello 3

file3hello 4

hello 7

Page 71: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Status

> echo ’hello 4’ > file3> echo ’hello 5’ >> file1> git status

# On branch master

# Changes not staged.. :

# modified: file1

#

# Untracked files:

# file3

> git log

commit 2

Author: Its Me

Date: Feb 6 15:21:38 2014

updated file2

...

>

git diff file1

diff --git a/file1 b/file1

hello 1

+hello 5

>

master

Local Repository

1 2

3 4

5 6

7

Index

file1 file2 file3

Staging Areafile1 file2

file3

Workspace

file1hello 1hello 5

file2hello 2hello 3

file3hello 4

hello 7

Page 72: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Status

> echo ’hello 4’ > file3> echo ’hello 5’ >> file1> git status

# On branch master

# Changes not staged.. :

# modified: file1

#

# Untracked files:

# file3

> git logcommit 2

Author: Its Me

Date: Feb 6 15:21:38 2014

updated file2

...

>

git diff file1diff --git a/file1 b/file1

hello 1

+hello 5

>

master

Local Repository

1 2

3 4

5 6

7

Index

file1 file2 file3

Staging Areafile1 file2

file3

Workspace

file1hello 1hello 5

file2hello 2hello 3

file3hello 4

hello 7

Page 73: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Status

> echo ’hello 4’ > file3> echo ’hello 5’ >> file1> git status

# On branch master

# Changes not staged.. :

# modified: file1

#

# Untracked files:

# file3

> git logcommit 2

Author: Its Me

Date: Feb 6 15:21:38 2014

updated file2

...

> git diff file1

diff --git a/file1 b/file1

hello 1

+hello 5

>

master

Local Repository

1 2

3 4

5 6

7

Index

file1 file2 file3

Staging Areafile1 file2

file3

Workspace

file1hello 1hello 5

file2hello 2hello 3

file3hello 4

hello 7

Page 74: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Status

> echo ’hello 4’ > file3> echo ’hello 5’ >> file1> git status

# On branch master

# Changes not staged.. :

# modified: file1

#

# Untracked files:

# file3

> git logcommit 2

Author: Its Me

Date: Feb 6 15:21:38 2014

updated file2

...

> git diff file1diff --git a/file1 b/file1

hello 1

+hello 5

>

master

Local Repository

1 2

3 4

5 6

7

Index

file1 file2 file3

Staging Areafile1 file2

file3

Workspace

file1hello 1hello 5

file2hello 2hello 3

file3hello 4

hello 7

Page 75: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Branching

1 Committing

2 Status

3 Branching

4 Merging

5 Revert, Reset and Delete

Page 76: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Branching

Local Remote

init

add

commit

statuslog

diff

checkout

branchmerge

revert

reset

remote

branch -u

clonepush

fetchpull

Workspace Staging Index+Repo Repo

Page 77: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Branching

>

git checkout 1>

git branch foo

>

git checkout foo

>

echo ’hello 4’ > file3

>

echo ’hello 5’ >> file1

>

git status

# On branch foo

# Changes not staged.. :

# modified: file1

#

# Untracked files:

# file3

>

git commit -am ’updated file1’

>

echo ’hello 6’ >> file2

>

git commit -am ’updated file2’

>

master

Local Repository

1 2

3 4

5 6

7

Index

file1 file2 file3

Staging Areafile1 file2

file3

Workspace

file1hello 1

hello 5

file2hello 2hello 3

file3hello 4

hello 7

Page 78: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Branching

> git checkout 1

>

git branch foo

>

git checkout foo

>

echo ’hello 4’ > file3

>

echo ’hello 5’ >> file1

>

git status

# On branch foo

# Changes not staged.. :

# modified: file1

#

# Untracked files:

# file3

>

git commit -am ’updated file1’

>

echo ’hello 6’ >> file2

>

git commit -am ’updated file2’

>

master

Local Repository

1 2

3 4

5 6

7

Index

file1 file2 file3

Staging Areafile1 file2

file3

Workspace

file1hello 1

hello 5

file2hello 2hello 3

file3hello 4

hello 7

Page 79: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Branching

> git checkout 1>

git branch foo>

git checkout foo

>

echo ’hello 4’ > file3

>

echo ’hello 5’ >> file1

>

git status

# On branch foo

# Changes not staged.. :

# modified: file1

#

# Untracked files:

# file3

>

git commit -am ’updated file1’

>

echo ’hello 6’ >> file2

>

git commit -am ’updated file2’

>

master

Local Repository

1 2

3 4

5 6

7

Index

file1 file2 file3

Staging Areafile1 file2

file3

Workspace

file1hello 1

hello 5

file2hello 2

file3hello 4

hello 7

Page 80: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Branching

> git checkout 1> git branch foo

>

git checkout foo

>

echo ’hello 4’ > file3

>

echo ’hello 5’ >> file1

>

git status

# On branch foo

# Changes not staged.. :

# modified: file1

#

# Untracked files:

# file3

>

git commit -am ’updated file1’

>

echo ’hello 6’ >> file2

>

git commit -am ’updated file2’

>

master

Local Repository

1 2

3 4

5 6

7

Index

file1 file2 file3

Staging Areafile1 file2

file3

Workspace

file1hello 1

hello 5

file2hello 2

file3hello 4

hello 7

Page 81: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Branching

> git checkout 1> git branch foo>

git checkout foo>

echo ’hello 4’ > file3

>

echo ’hello 5’ >> file1

>

git status

# On branch foo

# Changes not staged.. :

# modified: file1

#

# Untracked files:

# file3

>

git commit -am ’updated file1’

>

echo ’hello 6’ >> file2

>

git commit -am ’updated file2’

>

master

foo

Local Repository

1 2

3 4

5 6

7

Index

file1 file2 file3

Staging Areafile1 file2

file3

Workspace

file1hello 1

hello 5

file2hello 2

file3hello 4

hello 7

Page 82: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Branching

> git checkout 1> git branch foo> git checkout foo

>

echo ’hello 4’ > file3

>

echo ’hello 5’ >> file1

>

git status

# On branch foo

# Changes not staged.. :

# modified: file1

#

# Untracked files:

# file3

>

git commit -am ’updated file1’

>

echo ’hello 6’ >> file2

>

git commit -am ’updated file2’

>

master

foo

Local Repository

1 2

3 4

5 6

7

Index

file1 file2 file3

Staging Areafile1 file2

file3

Workspace

file1hello 1

hello 5

file2hello 2

file3hello 4

hello 7

Page 83: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Branching

> git checkout 1> git branch foo> git checkout foo>

echo ’hello 4’ > file3>

echo ’hello 5’ >> file1

>

git status

# On branch foo

# Changes not staged.. :

# modified: file1

#

# Untracked files:

# file3

>

git commit -am ’updated file1’

>

echo ’hello 6’ >> file2

>

git commit -am ’updated file2’

>

master

foo

Local Repository

1 2

3 4

5 6

7

Index

file1 file2 file3

Staging Areafile1 file2

file3

Workspace

file1hello 1

hello 5

file2hello 2

file3hello 4

hello 7

Page 84: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Branching

> git checkout 1> git branch foo> git checkout foo> echo ’hello 4’ > file3

>

echo ’hello 5’ >> file1

>

git status

# On branch foo

# Changes not staged.. :

# modified: file1

#

# Untracked files:

# file3

>

git commit -am ’updated file1’

>

echo ’hello 6’ >> file2

>

git commit -am ’updated file2’

>

master

foo

Local Repository

1 2

3 4

5 6

7

Index

file1 file2 file3

Staging Areafile1 file2

file3

Workspace

file1hello 1

hello 5

file2hello 2

file3hello 4

hello 7

Page 85: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Branching

> git checkout 1> git branch foo> git checkout foo> echo ’hello 4’ > file3>

echo ’hello 5’ >> file1>

git status

# On branch foo

# Changes not staged.. :

# modified: file1

#

# Untracked files:

# file3

>

git commit -am ’updated file1’

>

echo ’hello 6’ >> file2

>

git commit -am ’updated file2’

>

master

foo

Local Repository

1 2

3 4

5 6

7

Index

file1 file2 file3

Staging Areafile1 file2

file3

Workspace

file1hello 1

hello 5

file2hello 2

file3hello 4

hello 7

Page 86: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Branching

> git checkout 1> git branch foo> git checkout foo> echo ’hello 4’ > file3> echo ’hello 5’ >> file1

>

git status

# On branch foo

# Changes not staged.. :

# modified: file1

#

# Untracked files:

# file3

>

git commit -am ’updated file1’

>

echo ’hello 6’ >> file2

>

git commit -am ’updated file2’

>

master

foo

Local Repository

1 2

3 4

5 6

7

Index

file1 file2 file3

Staging Areafile1 file2

file3

Workspace

file1hello 1

hello 5

file2hello 2

file3hello 4

hello 7

Page 87: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Branching

> git checkout 1> git branch foo> git checkout foo> echo ’hello 4’ > file3> echo ’hello 5’ >> file1>

git status

# On branch foo

# Changes not staged.. :

# modified: file1

#

# Untracked files:

# file3

>

git commit -am ’updated file1’

>

echo ’hello 6’ >> file2

>

git commit -am ’updated file2’

>

master

foo

Local Repository

1 2

3 4

5 6

7

Index

file1 file2 file3

Staging Areafile1 file2

file3

Workspace

file1hello 1hello 5

file2hello 2

file3hello 4

hello 7

Page 88: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Branching

> git checkout 1> git branch foo> git checkout foo> echo ’hello 4’ > file3> echo ’hello 5’ >> file1> git status

# On branch foo

# Changes not staged.. :

# modified: file1

#

# Untracked files:

# file3

>

git commit -am ’updated file1’

>

echo ’hello 6’ >> file2

>

git commit -am ’updated file2’

>

master

foo

Local Repository

1 2

3 4

5 6

7

Index

file1 file2 file3

Staging Areafile1 file2

file3

Workspace

file1hello 1hello 5

file2hello 2

file3hello 4

hello 7

Page 89: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Branching

> git checkout 1> git branch foo> git checkout foo> echo ’hello 4’ > file3> echo ’hello 5’ >> file1> git status

# On branch foo

# Changes not staged.. :

# modified: file1

#

# Untracked files:

# file3

>

git commit -am ’updated file1’>

echo ’hello 6’ >> file2

>

git commit -am ’updated file2’

>

master

foo

Local Repository

1 2

3 4

5 6

7

Index

file1 file2 file3

Staging Areafile1 file2

file3

Workspace

file1hello 1hello 5

file2hello 2

file3hello 4

hello 7

Page 90: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Branching

> git checkout 1> git branch foo> git checkout foo> echo ’hello 4’ > file3> echo ’hello 5’ >> file1> git status

# On branch foo

# Changes not staged.. :

# modified: file1

#

# Untracked files:

# file3

> git commit -am ’updated file1’

>

echo ’hello 6’ >> file2

>

git commit -am ’updated file2’

>

master

foo

Local Repository

1 2

3 4

5 6

7

Indexfile1

file2 file3

Staging Areafile1 file2

file3

Workspace

file1hello 1hello 5

file2hello 2

file3hello 4

hello 7

Page 91: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Branching

> git checkout 1> git branch foo> git checkout foo> echo ’hello 4’ > file3> echo ’hello 5’ >> file1> git status

# On branch foo

# Changes not staged.. :

# modified: file1

#

# Untracked files:

# file3

> git commit -am ’updated file1’>

echo ’hello 6’ >> file2>

git commit -am ’updated file2’

>

master

foo

Local Repository

1 2

3

4

5 6

7

Index

file1 file2 file3

Staging Areafile1 file2

file3

Workspace

file1hello 1hello 5

file2hello 2

file3hello 4

hello 7

Page 92: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Branching

> git checkout 1> git branch foo> git checkout foo> echo ’hello 4’ > file3> echo ’hello 5’ >> file1> git status

# On branch foo

# Changes not staged.. :

# modified: file1

#

# Untracked files:

# file3

> git commit -am ’updated file1’> echo ’hello 6’ >> file2

>

git commit -am ’updated file2’

>

master

foo

Local Repository

1 2

3

4

5 6

7

Index

file1 file2 file3

Staging Areafile1 file2

file3

Workspace

file1hello 1hello 5

file2hello 2

file3hello 4

hello 7

Page 93: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Branching

> git checkout 1> git branch foo> git checkout foo> echo ’hello 4’ > file3> echo ’hello 5’ >> file1> git status

# On branch foo

# Changes not staged.. :

# modified: file1

#

# Untracked files:

# file3

> git commit -am ’updated file1’> echo ’hello 6’ >> file2>

git commit -am ’updated file2’>

master

foo

Local Repository

1 2

3

4

5 6

7

Index

file1 file2 file3

Staging Areafile1 file2

file3

Workspace

file1hello 1hello 5

file2hello 2hello 6

file3hello 4

hello 7

Page 94: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Branching

> git checkout 1> git branch foo> git checkout foo> echo ’hello 4’ > file3> echo ’hello 5’ >> file1> git status

# On branch foo

# Changes not staged.. :

# modified: file1

#

# Untracked files:

# file3

> git commit -am ’updated file1’> echo ’hello 6’ >> file2> git commit -am ’updated file2’

>

master

foo

Local Repository

1 2

3

4

5 6

7

Index

file1

file2

file3

Staging Areafile1 file2

file3

Workspace

file1hello 1hello 5

file2hello 2hello 6

file3hello 4

hello 7

Page 95: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Branching

> git checkout 1> git branch foo> git checkout foo> echo ’hello 4’ > file3> echo ’hello 5’ >> file1> git status

# On branch foo

# Changes not staged.. :

# modified: file1

#

# Untracked files:

# file3

> git commit -am ’updated file1’> echo ’hello 6’ >> file2> git commit -am ’updated file2’>

master

foo

Local Repository

1 2

3 4

5 6

7

Index

file1 file2 file3

Staging Areafile1 file2

file3

Workspace

file1hello 1hello 5

file2hello 2hello 6

file3hello 4

hello 7

Page 96: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Merging

1 Committing

2 Status

3 Branching

4 Merging

5 Revert, Reset and Delete

Page 97: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Merging

Local Remote

init

add

commit

statuslog

diff

checkout

branchmerge

revert

reset

remote

branch -u

clonepush

fetchpull

Workspace Staging Index+Repo Repo

Page 98: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Merging

>

git checkout master>

git merge foo

Auto-merging file2

CONFLICT (content):

Merge conflict in file2

Automatic merge failed;

fix conflicts and commit.

>

vim file2

>

git add .

>

git commit -m ’foo merged’

>

master

foo

Local Repository

1 2

3 4

5 6

7

Index

file1 file2 file3

Staging Areafile1 file2

file3

Workspace

file1hello 1hello 5

file2hello 2hello 6

file3hello 4

hello 7

Page 99: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Merging

> git checkout master

>

git merge foo

Auto-merging file2

CONFLICT (content):

Merge conflict in file2

Automatic merge failed;

fix conflicts and commit.

>

vim file2

>

git add .

>

git commit -m ’foo merged’

>

master

foo

Local Repository

1 2

3 4

5 6

7

Index

file1 file2 file3

Staging Areafile1 file2

file3

Workspace

file1hello 1hello 5

file2hello 2hello 6

file3hello 4

hello 7

Page 100: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Merging

> git checkout master>

git merge foo

Auto-merging file2

CONFLICT (content):

Merge conflict in file2

Automatic merge failed;

fix conflicts and commit.

>

vim file2

>

git add .

>

git commit -m ’foo merged’

>

master

foo

Local Repository

1 2

3 4

5 6

7

Index

file1 file2 file3

Staging Areafile1 file2

file3

Workspace

file1hello 1

hello 5

file2hello 2hello 3

file3hello 4

hello 7

Page 101: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Merging

> git checkout master> git merge foo

Auto-merging file2

CONFLICT (content):

Merge conflict in file2

Automatic merge failed;

fix conflicts and commit.

>

vim file2

>

git add .

>

git commit -m ’foo merged’

>

master

foo

Local Repository

1 2

3 4

5 6

7

Index

file1 file2 file3

Staging Areafile1 file2

file3

Workspace

file1hello 1

hello 5

file2hello 2hello 3

file3hello 4

hello 7

Page 102: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Merging

> git checkout master> git merge foo

Auto-merging file2

CONFLICT (content):

Merge conflict in file2

Automatic merge failed;

fix conflicts and commit.

>

vim file2>

git add .

>

git commit -m ’foo merged’

>

master

foo

Local Repository

1 2

3 4

5 6

7

Index

file1 file2 file3

Staging Areafile1 file2

file3

Workspace

file1hello 1hello 5

file2hello 2<<< headhello 3==hello 6>>> foo

file3hello 4

hello 7

Page 103: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Merging

> git checkout master> git merge foo

Auto-merging file2

CONFLICT (content):

Merge conflict in file2

Automatic merge failed;

fix conflicts and commit.

> vim file2

>

git add .

>

git commit -m ’foo merged’

>

master

foo

Local Repository

1 2

3 4

5 6

7

Index

file1 file2 file3

Staging Areafile1 file2

file3

Workspace

file1hello 1hello 5

file2hello 2<<< headhello 3==hello 6>>> foo

file3hello 4

hello 7

Page 104: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Merging

> git checkout master> git merge foo

Auto-merging file2

CONFLICT (content):

Merge conflict in file2

Automatic merge failed;

fix conflicts and commit.

> vim file2>

git add .>

git commit -m ’foo merged’

>

master

foo

Local Repository

1 2

3 4

5 6

7

Index

file1 file2 file3

Staging Areafile1 file2

file3

Workspace

file1hello 1hello 5

file2hello 2hello 3hello 6

file3hello 4

hello 7

Page 105: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Merging

> git checkout master> git merge foo

Auto-merging file2

CONFLICT (content):

Merge conflict in file2

Automatic merge failed;

fix conflicts and commit.

> vim file2> git add .

>

git commit -m ’foo merged’

>

master

foo

Local Repository

1 2

3 4

5 6

7

Index

file1 file2 file3

Staging Areafile1 file2

file3

Workspace

file1hello 1hello 5

file2hello 2hello 3hello 6

file3hello 4

hello 7

Page 106: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Merging

> git checkout master> git merge foo

Auto-merging file2

CONFLICT (content):

Merge conflict in file2

Automatic merge failed;

fix conflicts and commit.

> vim file2> git add .>

git commit -m ’foo merged’>

master

foo

Local Repository

1 2

3 4

5 6

7

Indexfile1 file2 file3

Staging Areafile1 file2

file3

Workspace

file1hello 1hello 5

file2hello 2hello 3hello 6

file3hello 4

hello 7

Page 107: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Merging

> git checkout master> git merge foo

Auto-merging file2

CONFLICT (content):

Merge conflict in file2

Automatic merge failed;

fix conflicts and commit.

> vim file2> git add .> git commit -m ’foo merged’

>

master

foo

Local Repository

1 2

3 4

5 6

7

Indexfile1 file2 file3

Staging Areafile1 file2

file3

Workspace

file1hello 1hello 5

file2hello 2hello 3hello 6

file3hello 4

hello 7

Page 108: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Merging

> git checkout master> git merge foo

Auto-merging file2

CONFLICT (content):

Merge conflict in file2

Automatic merge failed;

fix conflicts and commit.

> vim file2> git add .> git commit -m ’foo merged’>

master

foo

Local Repository

1 2

3 4

5

6

7

Index

file1 file2 file3

Staging Areafile1 file2 file3

Workspace

file1hello 1hello 5

file2hello 2hello 3hello 6

file3hello 4

hello 7

Page 109: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Revert, Reset and Delete

1 Committing

2 Status

3 Branching

4 Merging

5 Revert, Reset and Delete

Page 110: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Revert, Reset and Delete

Local Remote

init

add

commit

statuslog

diff

checkout

branchmerge

revert

reset

remote

branch -u

clonepush

fetchpull

Workspace Staging Index+Repo Repo

Page 111: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Revert, Reset and Delete

>

echo ’hello 7’ >> file3>

git commit -am ’updated file3’

>

git revert 6

>

git branch -d foo

>

git reset

> dsljf lksjd flkjasdfl aksjd flaksjdflaksdjf lak alsdj alfksdj

master

foo

Local Repository

1 2

3 4

5

6

7

Index

file1 file2 file3

Staging Areafile1 file2 file3

Workspace

file1hello 1hello 5

file2hello 2hello 3hello 6

file3hello 4

hello 7

Page 112: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Revert, Reset and Delete

> echo ’hello 7’ >> file3

>

git commit -am ’updated file3’

>

git revert 6

>

git branch -d foo

>

git reset

> dsljf lksjd flkjasdfl aksjd flaksjdflaksdjf lak alsdj alfksdj

master

foo

Local Repository

1 2

3 4

5

6

7

Index

file1 file2 file3

Staging Areafile1 file2 file3

Workspace

file1hello 1hello 5

file2hello 2hello 3hello 6

file3hello 4

hello 7

Page 113: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Revert, Reset and Delete

> echo ’hello 7’ >> file3>

git commit -am ’updated file3’>

git revert 6

>

git branch -d foo

>

git reset

> dsljf lksjd flkjasdfl aksjd flaksjdflaksdjf lak alsdj alfksdj

master

foo

Local Repository

1 2

3 4

5

6

7

Index

file1 file2 file3

Staging Areafile1 file2 file3

Workspace

file1hello 1hello 5

file2hello 2hello 3hello 6

file3hello 4hello 7

Page 114: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Revert, Reset and Delete

> echo ’hello 7’ >> file3> git commit -am ’updated file3’

>

git revert 6

>

git branch -d foo

>

git reset

> dsljf lksjd flkjasdfl aksjd flaksjdflaksdjf lak alsdj alfksdj

master

foo

Local Repository

1 2

3 4

5

6

7

Index

file1 file2

file3

Staging Areafile1 file2 file3

Workspace

file1hello 1hello 5

file2hello 2hello 3hello 6

file3hello 4hello 7

Page 115: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Revert, Reset and Delete

> echo ’hello 7’ >> file3> git commit -am ’updated file3’>

git revert 6>

git branch -d foo

>

git reset

> dsljf lksjd flkjasdfl aksjd flaksjdflaksdjf lak alsdj alfksdj

master

foo

Local Repository

1 2

3 4

5 6

7

Index

file1 file2 file3

Staging Areafile1 file2 file3

Workspace

file1hello 1hello 5

file2hello 2hello 3hello 6

file3hello 4hello 7

Page 116: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Revert, Reset and Delete

> echo ’hello 7’ >> file3> git commit -am ’updated file3’> git revert 6

>

git branch -d foo

>

git reset

> dsljf lksjd flkjasdfl aksjd flaksjdflaksdjf lak alsdj alfksdj

master

foo

Local Repository

1 2

3 4

5 6

7

Index

file1 file2 file3

Staging Areafile1 file2 file3

Workspace

file1hello 1hello 5

file2hello 2hello 3hello 6

file3hello 4hello 7

Page 117: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Revert, Reset and Delete

> echo ’hello 7’ >> file3> git commit -am ’updated file3’> git revert 6>

git branch -d foo>

git reset

> dsljf lksjd flkjasdfl aksjd flaksjdflaksdjf lak alsdj alfksdj

masterfoo

Local Repository

1 2

3 4

5 6

7

Index

file1 file2 file3

Staging Areafile1 file2 file3

Workspace

file1hello 1hello 5

file2hello 2hello 3hello 6

file3hello 4

hello 7

Page 118: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Revert, Reset and Delete

> echo ’hello 7’ >> file3> git commit -am ’updated file3’> git revert 6> git branch -d foo

>

git reset

> dsljf lksjd flkjasdfl aksjd flaksjdflaksdjf lak alsdj alfksdj

masterfoo

Local Repository

1 2

3 4

5 6

7

Index

file1 file2 file3

Staging Areafile1 file2 file3

Workspace

file1hello 1hello 5

file2hello 2hello 3hello 6

file3hello 4

hello 7

Page 119: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Revert, Reset and Delete

> echo ’hello 7’ >> file3> git commit -am ’updated file3’> git revert 6> git branch -d foo>

git reset> dsljf lksjd flkjasdfl aksjd flaksjdflaksdjf lak alsdj alfksdj

master

Local Repository

1 2

3 4

5 6

7

Index

file1 file2 file3

Staging Areafile1 file2 file3

Workspace

file1hello 1hello 5

file2hello 2hello 3hello 6

file3hello 4

hello 7

Page 120: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Revert, Reset and Delete

> echo ’hello 7’ >> file3> git commit -am ’updated file3’> git revert 6> git branch -d foo> git reset --hard 2

> dsljf lksjd flkjasdfl aksjd flaksjdflaksdjf lak alsdj alfksdj

master

Local Repository

1 2

3 4

5 6

7

Index

file1 file2 file3

Staging Areafile1 file2 file3

Workspace

file1hello 1hello 5

file2hello 2hello 3hello 6

file3hello 4

hello 7

Page 121: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Revert, Reset and Delete

> echo ’hello 7’ >> file3> git commit -am ’updated file3’> git revert 6> git branch -d foo> git reset --hard 2>

dsljf lksjd flkjasdfl aksjd flaksjdflaksdjf lak alsdj alfksdj

master

Local Repository

1 2

3 4

5 6

7

Index

file1 file2 file3

Staging Areafile1 file2

file3

Workspace

file1hello 1

hello 5

file2hello 2hello 3

file3hello 4

hello 7

Page 122: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Revert, Reset and Delete

> echo ’hello 7’ >> file3> git commit -am ’updated file3’> git revert 6> git branch -d foo> git reset (--mixed) 2

> dsljf lksjd flkjasdfl aksjd flaksjdflaksdjf lak alsdj alfksdj

master

Local Repository

1 2

3 4

5 6

7

Index

file1 file2 file3

Staging Areafile1 file2 file3

Workspace

file1hello 1hello 5

file2hello 2hello 3hello 6

file3hello 4

hello 7

Page 123: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Revert, Reset and Delete

> echo ’hello 7’ >> file3> git commit -am ’updated file3’> git revert 6> git branch -d foo> git reset (--mixed) 2>

dsljf lksjd flkjasdfl aksjd flaksjdflaksdjf lak alsdj alfksdj

master

Local Repository

1 2

3 4

5 6

7

Index

file1 file2 file3

Staging Areafile1 file2

file3

Workspace

file1hello 1hello 5

file2hello 2hello 3hello 6

file3hello 4

hello 7

Page 124: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Revert, Reset and Delete

> echo ’hello 7’ >> file3> git commit -am ’updated file3’> git revert 6> git branch -d foo> git reset --soft 2

> dsljf lksjd flkjasdfl aksjd flaksjdflaksdjf lak alsdj alfksdj

master

Local Repository

1 2

3 4

5 6

7

Index

file1 file2 file3

Staging Areafile1 file2 file3

Workspace

file1hello 1hello 5

file2hello 2hello 3hello 6

file3hello 4

hello 7

Page 125: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Revert, Reset and Delete

> echo ’hello 7’ >> file3> git commit -am ’updated file3’> git revert 6> git branch -d foo> git reset --soft 2>

dsljf lksjd flkjasdfl aksjd flaksjdflaksdjf lak alsdj alfksdj

master

Local Repository

1 2

3 4

5 6

7

Index

file1 file2 file3

Staging Areafile1 file2 file3

Workspace

file1hello 1hello 5

file2hello 2hello 3hello 6

file3hello 4

hello 7

Page 126: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Local Repository

Local Remote

init

add

commit

statuslog

diff

checkout

branchmerge

revert

reset

remote

branch -u

clonepush

fetchpull

Workspace Staging Index+Repo Repo

Page 127: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Remote Repository

1 Creating and Connecting

2 Push and Pull

Page 128: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Creating and Connecting

1 Creating and Connecting

2 Push and Pull

Page 129: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Creating and Connecting

Local Remote

init

add

commit

statuslog

diff

checkout

branchmerge

t

revert

reset

remote

branch -u

clonepush

fetchpull

Workspace Staging Index+Repo Repo

Page 130: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Creating and Connecting

Remote does not exists:

local>

ssh [email protected]>

mkdir ∼/project.git

remote>

cd ∼/project.git

remote>

git init --bare

remote>

logout

local>

git remote add origin \[email protected]:∼/project.git

local>

git push origin master

local>

git branch -u \origin/master master

local>

Remote exists:

local>

git clone \[email protected]:∼/project.git

Cloning into ’project’...local>

(upstream)

master

Local Repository

1 2

Staging Areafile1 file2

Remote Repository

origin

1 2

Page 131: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Creating and Connecting

Remote does not exists:

local> ssh [email protected]

remote>

mkdir ∼/project.git

remote>

cd ∼/project.git

remote>

git init --bare

remote>

logout

local>

git remote add origin \[email protected]:∼/project.git

local>

git push origin master

local>

git branch -u \origin/master master

local>

Remote exists:

local>

git clone \[email protected]:∼/project.git

Cloning into ’project’...local>

(upstream)

master

Local Repository

1 2

Staging Areafile1 file2

Remote Repository

origin

1 2

Page 132: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Creating and Connecting

Remote does not exists:

local> ssh [email protected]>

mkdir ∼/project.gitremote>

cd ∼/project.git

remote>

git init --bare

remote>

logout

local>

git remote add origin \[email protected]:∼/project.git

local>

git push origin master

local>

git branch -u \origin/master master

local>

Remote exists:

local>

git clone \[email protected]:∼/project.git

Cloning into ’project’...local>

(upstream)

master

Local Repository

1 2

Staging Areafile1 file2

Remote Repository

origin

1 2

Page 133: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Creating and Connecting

Remote does not exists:

local> ssh [email protected]> mkdir ∼/project.git

remote>

cd ∼/project.git

remote>

git init --bare

remote>

logout

local>

git remote add origin \[email protected]:∼/project.git

local>

git push origin master

local>

git branch -u \origin/master master

local>

Remote exists:

local>

git clone \[email protected]:∼/project.git

Cloning into ’project’...local>

(upstream)

master

Local Repository

1 2

Staging Areafile1 file2

Remote Repository

origin

1 2

Page 134: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Creating and Connecting

Remote does not exists:

local> ssh [email protected]> mkdir ∼/project.gitremote>

cd ∼/project.gitremote>

git init --bare

remote>

logout

local>

git remote add origin \[email protected]:∼/project.git

local>

git push origin master

local>

git branch -u \origin/master master

local>

Remote exists:

local>

git clone \[email protected]:∼/project.git

Cloning into ’project’...local>

(upstream)

master

Local Repository

1 2

Staging Areafile1 file2

Remote Repository

origin

1 2

Page 135: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Creating and Connecting

Remote does not exists:

local> ssh [email protected]> mkdir ∼/project.gitremote> cd ∼/project.git

remote>

git init --bare

remote>

logout

local>

git remote add origin \[email protected]:∼/project.git

local>

git push origin master

local>

git branch -u \origin/master master

local>

Remote exists:

local>

git clone \[email protected]:∼/project.git

Cloning into ’project’...local>

(upstream)

master

Local Repository

1 2

Staging Areafile1 file2

Remote Repository

origin

1 2

Page 136: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Creating and Connecting

Remote does not exists:

local> ssh [email protected]> mkdir ∼/project.gitremote> cd ∼/project.gitremote>

git init --bareremote>

logout

local>

git remote add origin \[email protected]:∼/project.git

local>

git push origin master

local>

git branch -u \origin/master master

local>

Remote exists:

local>

git clone \[email protected]:∼/project.git

Cloning into ’project’...local>

(upstream)

master

Local Repository

1 2

Staging Areafile1 file2

Remote Repository

origin

1 2

Page 137: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Creating and Connecting

Remote does not exists:

local> ssh [email protected]> mkdir ∼/project.gitremote> cd ∼/project.gitremote> git init --bare

remote>

logout

local>

git remote add origin \[email protected]:∼/project.git

local>

git push origin master

local>

git branch -u \origin/master master

local>

Remote exists:

local>

git clone \[email protected]:∼/project.git

Cloning into ’project’...local>

(upstream)

master

Local Repository

1 2

Staging Areafile1 file2

Remote Repository

origin

1 2

Page 138: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Creating and Connecting

Remote does not exists:

local> ssh [email protected]> mkdir ∼/project.gitremote> cd ∼/project.gitremote> git init --bareremote>

logoutlocal>

git remote add origin \[email protected]:∼/project.git

local>

git push origin master

local>

git branch -u \origin/master master

local>

Remote exists:

local>

git clone \[email protected]:∼/project.git

Cloning into ’project’...local>

(upstream)

master

Local Repository

1 2

Staging Areafile1 file2

Remote Repository

origin

1 2

Page 139: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Creating and Connecting

Remote does not exists:

local> ssh [email protected]> mkdir ∼/project.gitremote> cd ∼/project.gitremote> git init --bareremote> logout

local>

git remote add origin \[email protected]:∼/project.git

local>

git push origin master

local>

git branch -u \origin/master master

local>

Remote exists:

local>

git clone \[email protected]:∼/project.git

Cloning into ’project’...local>

(upstream)

master

Local Repository

1 2

Staging Areafile1 file2

Remote Repository

origin

1 2

Page 140: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Creating and Connecting

Remote does not exists:

local> ssh [email protected]> mkdir ∼/project.gitremote> cd ∼/project.gitremote> git init --bareremote> logoutlocal>

git remote add origin \[email protected]:∼/project.git

local>

git push origin master

local>

git branch -u \origin/master master

local>

Remote exists:

local>

git clone \[email protected]:∼/project.git

Cloning into ’project’...local>

(upstream)

master

Local Repository

1 2

Staging Areafile1 file2

Remote Repository

origin

1 2

Page 141: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Creating and Connecting

Remote does not exists:

local> ssh [email protected]> mkdir ∼/project.gitremote> cd ∼/project.gitremote> git init --bareremote> logoutlocal> git remote add origin \

[email protected]:∼/project.git

local>

git push origin master

local>

git branch -u \origin/master master

local>

Remote exists:

local>

git clone \[email protected]:∼/project.git

Cloning into ’project’...local>

(upstream)

master

Local Repository

1 2

Staging Areafile1 file2

Remote Repository

origin

1 2

Page 142: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Creating and Connecting

Remote does not exists:

local> ssh [email protected]> mkdir ∼/project.gitremote> cd ∼/project.gitremote> git init --bareremote> logoutlocal> git remote add origin \

[email protected]:∼/project.gitlocal>

git push origin masterlocal>

git branch -u \origin/master master

local>

Remote exists:

local>

git clone \[email protected]:∼/project.git

Cloning into ’project’...local>

(upstream)

master

Local Repository

1 2

Staging Areafile1 file2

Remote Repository

origin

1 2

Page 143: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Creating and Connecting

Remote does not exists:

local> ssh [email protected]> mkdir ∼/project.gitremote> cd ∼/project.gitremote> git init --bareremote> logoutlocal> git remote add origin \

[email protected]:∼/project.gitlocal> git push origin master

local>

git branch -u \origin/master master

local>

Remote exists:

local>

git clone \[email protected]:∼/project.git

Cloning into ’project’...local>

(upstream)

master

Local Repository

1 2

Staging Areafile1 file2

Remote Repository

origin

1 2

Page 144: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Creating and Connecting

Remote does not exists:

local> ssh [email protected]> mkdir ∼/project.gitremote> cd ∼/project.gitremote> git init --bareremote> logoutlocal> git remote add origin \

[email protected]:∼/project.gitlocal> git push origin masterlocal>

git branch -u \origin/master master

local>

Remote exists:

local>

git clone \[email protected]:∼/project.git

Cloning into ’project’...local>

(upstream)

master

Local Repository

1 2

Staging Areafile1 file2

Remote Repository

origin

master

1 2

Page 145: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Creating and Connecting

Remote does not exists:

local> ssh [email protected]> mkdir ∼/project.gitremote> cd ∼/project.gitremote> git init --bareremote> logoutlocal> git remote add origin \

[email protected]:∼/project.gitlocal> git push origin masterlocal> git branch -u \

origin/master master

local>

Remote exists:

local>

git clone \[email protected]:∼/project.git

Cloning into ’project’...local>

(upstream)

master

Local Repository

1 2

Staging Areafile1 file2

Remote Repository

origin

master

1 2

Page 146: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Creating and Connecting

Remote does not exists:

local> ssh [email protected]> mkdir ∼/project.gitremote> cd ∼/project.gitremote> git init --bareremote> logoutlocal> git remote add origin \

[email protected]:∼/project.gitlocal> git push origin masterlocal> git branch -u \

origin/master masterlocal>

Remote exists:

local>

git clone \[email protected]:∼/project.git

Cloning into ’project’...local>

(upstream)

master

Local Repository

1 2

Staging Areafile1 file2

Remote Repository

origin

master

1 2

Page 147: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Creating and Connecting

Remote does not exists:

local> ssh [email protected]> mkdir ∼/project.gitremote> cd ∼/project.gitremote> git init --bareremote> logoutlocal> git remote add origin \

[email protected]:∼/project.gitlocal> git push origin masterlocal> git branch -u \

origin/master masterlocal>

Remote exists:

local>

git clone \[email protected]:∼/project.git

Cloning into ’project’...local>

(upstream)

Local Repository

1 2

Staging Area

file1 file2

Remote Repository

origin

master

1 2

Page 148: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Creating and Connecting

Remote does not exists:

local> ssh [email protected]> mkdir ∼/project.gitremote> cd ∼/project.gitremote> git init --bareremote> logoutlocal> git remote add origin \

[email protected]:∼/project.gitlocal> git push origin masterlocal> git branch -u \

origin/master masterlocal>

Remote exists:

local> git clone \[email protected]:∼/project.git

Cloning into ’project’...local>

(upstream)

Local Repository

1 2

Staging Area

file1 file2

Remote Repository

origin

master

1 2

Page 149: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Creating and Connecting

Remote does not exists:

local> ssh [email protected]> mkdir ∼/project.gitremote> cd ∼/project.gitremote> git init --bareremote> logoutlocal> git remote add origin \

[email protected]:∼/project.gitlocal> git push origin masterlocal> git branch -u \

origin/master masterlocal>

Remote exists:

local> git clone \[email protected]:∼/project.git

Cloning into ’project’...local>

(upstream)

master

Local Repository

1 2

Staging Areafile1 file2

Remote Repository

origin

master

1 2

Page 150: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Push and Pull

1 Creating and Connecting

2 Push and Pull

Page 151: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Push and Pull

Local Remote

init

add

commit

statuslog

diff

checkout

branchmerge

t

revert

reset

remote

branch -u

clonepush

fetchpull

Workspace Staging Index+Repo Repo

Page 152: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Push and Pull

Local is ahead of Remote

>

git push>

Remote is ahead of Local

>

git pull

>

git pull = git fetch & git merge

(upstream)

master

Local Repository

1 2

Staging Areafile1 file2

Remote Repository

origin

master

1

2

Page 153: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Push and Pull

Local is ahead of Remote

> git push

>

Remote is ahead of Local

>

git pull

>

git pull = git fetch & git merge

(upstream)

master

Local Repository

1 2

Staging Areafile1 file2

Remote Repository

origin

master

1

2

Page 154: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Push and Pull

Local is ahead of Remote

> git push>

Remote is ahead of Local

>

git pull

>

git pull = git fetch & git merge

(upstream)

master

Local Repository

1 2

Staging Areafile1 file2

Remote Repository

origin

master

1 2

Page 155: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Push and Pull

Local is ahead of Remote

> git push>

Remote is ahead of Local

>

git pull>

git pull = git fetch & git merge

(upstream)

master

Local Repository

1

2

Staging Areafile1

file2

Remote Repository

origin

master

1 2

Page 156: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Push and Pull

Local is ahead of Remote

> git push>

Remote is ahead of Local

> git pull

>

git pull = git fetch & git merge

(upstream)

master

Local Repository

1

2

Staging Areafile1

file2

Remote Repository

origin

master

1 2

Page 157: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Push and Pull

Local is ahead of Remote

> git push>

Remote is ahead of Local

> git pull>

git pull = git fetch & git merge

(upstream)

master

Local Repository

1 2

Staging Areafile1 file2

Remote Repository

origin

master

1 2

Page 158: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Remote Repository

Local Remote

init

add

commit

statuslog

diff

checkout

branchmerge

t

revert

reset

remote

branch -u

clonepush

fetchpull

Workspace Staging Index+Repo Repo

Page 159: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

The Commands

Local Remote

init

add

commit

statuslog

diff

checkout

branchmerge

t

revert

reset

remote

branch -u

clonepush

fetchpull

Workspace Staging Index+Repo Repo

Page 160: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

The Commands: Committing

Local Remote

init*

add*

commit*

statuslog

diff

checkout

branchmerge

t

revert

reset

remote

branch -u

clonepush

fetchpull

Workspace Staging Index+Repo Repo

Page 161: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

The Commands: Status

Local Remote

init

add

commit

status*log*

diff*

checkout

branchmerge

t

revert

reset

remote

branch -u

clonepush

fetchpull

Workspace Staging Index+Repo Repo

Page 162: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

The Commands: Branching

Local Remote

init

add

commit

statuslog

diff

checkout*

branch*merge*

t

revert

reset

remote

branch -u

clonepush

fetchpull

Workspace Staging Index+Repo Repo

Page 163: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

The Commands: Alter Commit History

Local Remote

init

add

commit

statuslog

diff

checkout

branch*merge

t

revert*

reset*

remote

branch -u

clonepush

fetchpull

Workspace Staging Index+Repo Repo

Page 164: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

The Commands: Connect to Remote

Local Remote

init

add

commit

statuslog

diff

checkout

branchmerge

t

revert

reset

remote*

branch -u*

clone*push

fetchpull

Workspace Staging Index+Repo Repo

Page 165: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

The Commands: Local-Remote Data Exchange

Local Remote

init

add

commit

statuslog

diff

checkout

branchmerge

t

revert

reset

remote

branch -u

clonepush*

fetch*pull*

Workspace Staging Index+Repo Repo

Page 166: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Outline

1 Introduction

2 ArchitectureCVCS vs DVCSSVN vs GIT

3 CommandsLocal RepositoryRemote Repository

4 Workflow

5 Tips and Tricks

Page 167: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Workflow

We have seen WHAT commands to use,a workflow determines HOW to use them.

Page 168: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Workflow: The Wrong Way!

master

develop feature

Initial commit

First release

New function with bug

Bug fixed

Minor Improvement

Second release

Minor improvement

Second release

1

2

3

4

5

6

7

8

Page 169: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Workflow: Adding Structure

master develop feature

Initial commit

Working version

First release

New function with bug

Bug fixed

Update working version

Minor improvement

Second release

7

8

Page 170: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Workflow: Adding Structure

master develop feature

Initial commit

Working version

First release

New function with bug

Bug fixed

Update working version

Minor improvement

Second release

1

7

8

Page 171: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Workflow: Adding Structure

master develop feature

Initial commit

Working version

First release

New function with bug

Bug fixed

Update working version

Minor improvement

Second release

1

2

7

8

Page 172: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Workflow: Adding Structure

master develop feature

Initial commit

Working version

First release

New function with bug

Bug fixed

Update working version

Minor improvement

Second release

1

2

3

7

8

Page 173: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Workflow: Adding Structure

master develop feature

Initial commit

Working version

First release

New function with bug

Bug fixed

Update working version

Minor improvement

Second release

1

2

3

4

7

8

Page 174: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Workflow: Adding Structure

master develop feature

Initial commit

Working version

First release

New function with bug

Bug fixed

Update working version

Minor improvement

Second release

1

2

3

4

5

7

8

Page 175: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Workflow: Adding Structure

master develop feature

Initial commit

Working version

First release

New function with bug

Bug fixed

Update working version

Minor improvement

Second release

1

2

3

4

5

6

7

8

Page 176: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Workflow: Adding Structure

master develop feature

Initial commit

Working version

First release

New function with bug

Bug fixed

Update working version

Minor improvement

Second release

1

2

3

4

5

6

7

8

Page 177: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Workflow: Adding Structure

master develop feature

Initial commit

Working version

First release

New function with bug

Bug fixed

Update working version

Minor improvement

Second release

1

2

3

4

5

6

7

8

Page 178: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Outline

1 Introduction

2 ArchitectureCVCS vs DVCSSVN vs GIT

3 CommandsLocal RepositoryRemote Repository

4 Workflow

5 Tips and Tricks

Page 179: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Tips and Tricks

Best Practice Tips

Ignore (Temporary) Files or Directories

Create Custom Commands

Page 180: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Tips and Tricks

Best practice

1 Use a development branch next to a release branch.2 Pull before Push.3 Append .git to directory of remote repository, e.g.,

project.git.4 GIT server without root privileges: use Gitolite to allow

other people access to repositories on your account. (orthe hard way: restricted SSH keys in combination with anaccess script.)

Cheat Sheet: http://ndpsoftware.com/git-cheatsheet.html

All configurations and customizations are located in∼/.gitconfig

Page 181: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Tips and Tricks

Best practice

1 Use a development branch next to a release branch.2 Pull before Push.3 Append .git to directory of remote repository, e.g.,

project.git.4 GIT server without root privileges: use Gitolite to allow

other people access to repositories on your account. (orthe hard way: restricted SSH keys in combination with anaccess script.)

Cheat Sheet: http://ndpsoftware.com/git-cheatsheet.html

All configurations and customizations are located in∼/.gitconfig

Page 182: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Tips and Tricks

Best practice

1 Use a development branch next to a release branch.2 Pull before Push.3 Append .git to directory of remote repository, e.g.,

project.git.4 GIT server without root privileges: use Gitolite to allow

other people access to repositories on your account. (orthe hard way: restricted SSH keys in combination with anaccess script.)

Cheat Sheet: http://ndpsoftware.com/git-cheatsheet.html

All configurations and customizations are located in∼/.gitconfig

Page 183: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Tips and Tricks

Best practice

1 Use a development branch next to a release branch.2 Pull before Push.3 Append .git to directory of remote repository, e.g.,

project.git.4 GIT server without root privileges: use Gitolite to allow

other people access to repositories on your account. (orthe hard way: restricted SSH keys in combination with anaccess script.)

Cheat Sheet: http://ndpsoftware.com/git-cheatsheet.html

All configurations and customizations are located in∼/.gitconfig

Page 184: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Tips and Tricks

Best practice

1 Use a development branch next to a release branch.2 Pull before Push.3 Append .git to directory of remote repository, e.g.,

project.git.4 GIT server without root privileges: use Gitolite to allow

other people access to repositories on your account. (orthe hard way: restricted SSH keys in combination with anaccess script.)

Cheat Sheet: http://ndpsoftware.com/git-cheatsheet.html

All configurations and customizations are located in∼/.gitconfig

Page 185: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Tips and Tricks

Best practice

1 Use a development branch next to a release branch.2 Pull before Push.3 Append .git to directory of remote repository, e.g.,

project.git.4 GIT server without root privileges: use Gitolite to allow

other people access to repositories on your account. (orthe hard way: restricted SSH keys in combination with anaccess script.)

Cheat Sheet: http://ndpsoftware.com/git-cheatsheet.html

All configurations and customizations are located in∼/.gitconfig

Page 186: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Tips and Tricks

Best practice

1 Use a development branch next to a release branch.2 Pull before Push.3 Append .git to directory of remote repository, e.g.,

project.git.4 GIT server without root privileges: use Gitolite to allow

other people access to repositories on your account. (orthe hard way: restricted SSH keys in combination with anaccess script.)

Cheat Sheet: http://ndpsoftware.com/git-cheatsheet.html

All configurations and customizations are located in∼/.gitconfig

Page 187: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Ignoring (Temporary) Files or Directories

All files in .gitignore

will be ignored:

>

echo ’hello 1’ > file1>

echo ’hello 2’ > file2

>

echo ’file2’ > .gitignore

>

git init

>

git add .

>

git commit -m ’initial’

>

Ignore with regex:

Ignore vim swap files, e.g.,file1.swp, file1.swo, file1...

*.sw?

Ignore editor backup files

*∼

Ignore OS generated files

.DS STORE

Thumbs.db

Local Repository

1

Index

file1 .giti*

Staging Area

file1 .giti*

Workspace

file1

hello 1

file2

hello 2

.gitignorefile2

Page 188: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Ignoring (Temporary) Files or Directories

All files in .gitignore

will be ignored:

> echo ’hello 1’ > file1

>

echo ’hello 2’ > file2

>

echo ’file2’ > .gitignore

>

git init

>

git add .

>

git commit -m ’initial’

>

Ignore with regex:

Ignore vim swap files, e.g.,file1.swp, file1.swo, file1...

*.sw?

Ignore editor backup files

*∼

Ignore OS generated files

.DS STORE

Thumbs.db

Local Repository

1

Index

file1 .giti*

Staging Area

file1 .giti*

Workspace

file1

hello 1

file2

hello 2

.gitignorefile2

Page 189: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Ignoring (Temporary) Files or Directories

All files in .gitignore

will be ignored:

> echo ’hello 1’ > file1>

echo ’hello 2’ > file2>

echo ’file2’ > .gitignore

>

git init

>

git add .

>

git commit -m ’initial’

>

Ignore with regex:

Ignore vim swap files, e.g.,file1.swp, file1.swo, file1...

*.sw?

Ignore editor backup files

*∼

Ignore OS generated files

.DS STORE

Thumbs.db

Local Repository

1

Index

file1 .giti*

Staging Area

file1 .giti*

Workspace

file1hello 1

file2

hello 2

.gitignorefile2

Page 190: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Ignoring (Temporary) Files or Directories

All files in .gitignore

will be ignored:

> echo ’hello 1’ > file1> echo ’hello 2’ > file2

>

echo ’file2’ > .gitignore

>

git init

>

git add .

>

git commit -m ’initial’

>

Ignore with regex:

Ignore vim swap files, e.g.,file1.swp, file1.swo, file1...

*.sw?

Ignore editor backup files

*∼

Ignore OS generated files

.DS STORE

Thumbs.db

Local Repository

1

Index

file1 .giti*

Staging Area

file1 .giti*

Workspace

file1hello 1

file2

hello 2

.gitignorefile2

Page 191: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Ignoring (Temporary) Files or Directories

All files in .gitignore

will be ignored:

> echo ’hello 1’ > file1> echo ’hello 2’ > file2>

echo ’file2’ > .gitignore>

git init

>

git add .

>

git commit -m ’initial’

>

Ignore with regex:

Ignore vim swap files, e.g.,file1.swp, file1.swo, file1...

*.sw?

Ignore editor backup files

*∼

Ignore OS generated files

.DS STORE

Thumbs.db

Local Repository

1

Index

file1 .giti*

Staging Area

file1 .giti*

Workspace

file1hello 1

file2hello 2

.gitignorefile2

Page 192: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Ignoring (Temporary) Files or Directories

All files in .gitignore

will be ignored:

> echo ’hello 1’ > file1> echo ’hello 2’ > file2> echo ’file2’ > .gitignore

>

git init

>

git add .

>

git commit -m ’initial’

>

Ignore with regex:

Ignore vim swap files, e.g.,file1.swp, file1.swo, file1...

*.sw?

Ignore editor backup files

*∼

Ignore OS generated files

.DS STORE

Thumbs.db

Local Repository

1

Index

file1 .giti*

Staging Area

file1 .giti*

Workspace

file1hello 1

file2hello 2

.gitignorefile2

Page 193: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Ignoring (Temporary) Files or Directories

All files in .gitignore

will be ignored:

> echo ’hello 1’ > file1> echo ’hello 2’ > file2> echo ’file2’ > .gitignore>

git init>

git add .

>

git commit -m ’initial’

>

Ignore with regex:

Ignore vim swap files, e.g.,file1.swp, file1.swo, file1...

*.sw?

Ignore editor backup files

*∼

Ignore OS generated files

.DS STORE

Thumbs.db

Local Repository

1

Index

file1 .giti*

Staging Area

file1 .giti*

Workspace

file1hello 1

file2hello 2

.gitignorefile2

Page 194: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Ignoring (Temporary) Files or Directories

All files in .gitignore

will be ignored:

> echo ’hello 1’ > file1> echo ’hello 2’ > file2> echo ’file2’ > .gitignore> git init

>

git add .

>

git commit -m ’initial’

>

Ignore with regex:

Ignore vim swap files, e.g.,file1.swp, file1.swo, file1...

*.sw?

Ignore editor backup files

*∼

Ignore OS generated files

.DS STORE

Thumbs.db

Local Repository

1

Index

file1 .giti*

Staging Area

file1 .giti*

Workspace

file1hello 1

file2hello 2

.gitignorefile2

Page 195: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Ignoring (Temporary) Files or Directories

All files in .gitignore

will be ignored:

> echo ’hello 1’ > file1> echo ’hello 2’ > file2> echo ’file2’ > .gitignore> git init>

git add .>

git commit -m ’initial’

>

Ignore with regex:

Ignore vim swap files, e.g.,file1.swp, file1.swo, file1...

*.sw?

Ignore editor backup files

*∼

Ignore OS generated files

.DS STORE

Thumbs.db

Local Repository

1

Index

file1 .giti*

Staging Area

file1 .giti*

Workspace

file1hello 1

file2hello 2

.gitignorefile2

Page 196: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Ignoring (Temporary) Files or Directories

All files in .gitignore

will be ignored:

> echo ’hello 1’ > file1> echo ’hello 2’ > file2> echo ’file2’ > .gitignore> git init> git add .

>

git commit -m ’initial’

>

Ignore with regex:

Ignore vim swap files, e.g.,file1.swp, file1.swo, file1...

*.sw?

Ignore editor backup files

*∼

Ignore OS generated files

.DS STORE

Thumbs.db

Local Repository

1

Index

file1 .giti*

Staging Area

file1 .giti*

Workspace

file1hello 1

file2hello 2

.gitignorefile2

Page 197: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Ignoring (Temporary) Files or Directories

All files in .gitignore

will be ignored:

> echo ’hello 1’ > file1> echo ’hello 2’ > file2> echo ’file2’ > .gitignore> git init> git add .>

git commit -m ’initial’>

Ignore with regex:

Ignore vim swap files, e.g.,file1.swp, file1.swo, file1...

*.sw?

Ignore editor backup files

*∼

Ignore OS generated files

.DS STORE

Thumbs.db

Local Repository

1

Indexfile1 .giti*

Staging Area

file1 .giti*

Workspace

file1hello 1

file2hello 2

.gitignorefile2

Page 198: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Ignoring (Temporary) Files or Directories

All files in .gitignore

will be ignored:

> echo ’hello 1’ > file1> echo ’hello 2’ > file2> echo ’file2’ > .gitignore> git init> git add .> git commit -m ’initial’

>

Ignore with regex:

Ignore vim swap files, e.g.,file1.swp, file1.swo, file1...

*.sw?

Ignore editor backup files

*∼

Ignore OS generated files

.DS STORE

Thumbs.db

Local Repository

1

Indexfile1 .giti*

Staging Area

file1 .giti*

Workspace

file1hello 1

file2hello 2

.gitignorefile2

Page 199: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Ignoring (Temporary) Files or Directories

All files in .gitignore

will be ignored:

> echo ’hello 1’ > file1> echo ’hello 2’ > file2> echo ’file2’ > .gitignore> git init> git add .> git commit -m ’initial’>

Ignore with regex:

Ignore vim swap files, e.g.,file1.swp, file1.swo, file1...

*.sw?

Ignore editor backup files

*∼

Ignore OS generated files

.DS STORE

Thumbs.db

master

Local Repository

1

Index

file1 .giti*

Staging Areafile1 .giti*

Workspace

file1hello 1

file2hello 2

.gitignorefile2

Page 200: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Ignoring (Temporary) Files or Directories

All files in .gitignore

will be ignored:

> echo ’hello 1’ > file1> echo ’hello 2’ > file2> echo ’file2’ > .gitignore> git init> git add .> git commit -m ’initial’>

Ignore with regex:

Ignore vim swap files, e.g.,file1.swp, file1.swo, file1...

*.sw?

Ignore editor backup files

*∼

Ignore OS generated files

.DS STORE

Thumbs.db

master

Local Repository

1

Index

file1 .giti*

Staging Areafile1 .giti*

Workspace

file1hello 1

file2hello 2

.gitignorefile2

Page 201: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Ignoring (Temporary) Files or Directories

All files in .gitignore

will be ignored:

> echo ’hello 1’ > file1> echo ’hello 2’ > file2> echo ’file2’ > .gitignore> git init> git add .> git commit -m ’initial’>

Ignore with regex:

Ignore vim swap files, e.g.,file1.swp, file1.swo, file1...

*.sw?

Ignore editor backup files

*∼

Ignore OS generated files

.DS STORE

Thumbs.db

master

Local Repository

1

Index

file1 .giti*

Staging Areafile1 .giti*

Workspace

file1hello 1

file2hello 2

.gitignorefile2

Page 202: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Ignoring (Temporary) Files or Directories

All files in .gitignore

will be ignored:

> echo ’hello 1’ > file1> echo ’hello 2’ > file2> echo ’file2’ > .gitignore> git init> git add .> git commit -m ’initial’>

Ignore with regex:

Ignore vim swap files, e.g.,file1.swp, file1.swo, file1...*.sw?

Ignore editor backup files

*∼

Ignore OS generated files

.DS STORE

Thumbs.db

master

Local Repository

1

Index

file1 .giti*

Staging Areafile1 .giti*

Workspace

file1hello 1

file2hello 2

.gitignorefile2*.sw?

Page 203: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Ignoring (Temporary) Files or Directories

All files in .gitignore

will be ignored:

> echo ’hello 1’ > file1> echo ’hello 2’ > file2> echo ’file2’ > .gitignore> git init> git add .> git commit -m ’initial’>

Ignore with regex:

Ignore vim swap files, e.g.,file1.swp, file1.swo, file1...*.sw?

Ignore editor backup files

*∼

Ignore OS generated files

.DS STORE

Thumbs.db

master

Local Repository

1

Index

file1 .giti*

Staging Areafile1 .giti*

Workspace

file1hello 1

file2hello 2

.gitignorefile2*.sw?

Page 204: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Ignoring (Temporary) Files or Directories

All files in .gitignore

will be ignored:

> echo ’hello 1’ > file1> echo ’hello 2’ > file2> echo ’file2’ > .gitignore> git init> git add .> git commit -m ’initial’>

Ignore with regex:

Ignore vim swap files, e.g.,file1.swp, file1.swo, file1...*.sw?

Ignore editor backup files*∼

Ignore OS generated files

.DS STORE

Thumbs.db

master

Local Repository

1

Index

file1 .giti*

Staging Areafile1 .giti*

Workspace

file1hello 1

file2hello 2

.gitignorefile2*.sw?*∼

Page 205: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Ignoring (Temporary) Files or Directories

All files in .gitignore

will be ignored:

> echo ’hello 1’ > file1> echo ’hello 2’ > file2> echo ’file2’ > .gitignore> git init> git add .> git commit -m ’initial’>

Ignore with regex:

Ignore vim swap files, e.g.,file1.swp, file1.swo, file1...*.sw?

Ignore editor backup files*∼

Ignore OS generated files

.DS STORE

Thumbs.db

master

Local Repository

1

Index

file1 .giti*

Staging Areafile1 .giti*

Workspace

file1hello 1

file2hello 2

.gitignorefile2*.sw?*∼

Page 206: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Ignoring (Temporary) Files or Directories

All files in .gitignore

will be ignored:

> echo ’hello 1’ > file1> echo ’hello 2’ > file2> echo ’file2’ > .gitignore> git init> git add .> git commit -m ’initial’>

Ignore with regex:

Ignore vim swap files, e.g.,file1.swp, file1.swo, file1...*.sw?

Ignore editor backup files*∼

Ignore OS generated files.DS STORE

Thumbs.db

master

Local Repository

1

Index

file1 .giti*

Staging Areafile1 .giti*

Workspace

file1hello 1

file2hello 2

.gitignorefile2*.sw?*∼.DS ST...Thumbs...

Page 207: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Create Custom Commands

Aliases to commands in ∼/.gitconfig, i.e.[alias]

st = statusco = commit

Aliases to functions (you can find these in my config)

git ls

List files under version controlgit tar

Create tar file from files under version controlgit commit-now (alias: ’cn’)

Commit with timestamp as messagegit commit-now-push (alias: ’cnp’)

Push after a commit-now

git tree

Show commit history as colored tree structure

Page 208: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Create Custom Commands

Aliases to commands in ∼/.gitconfig, i.e.[alias]

st = statusco = commit

Aliases to functions (you can find these in my config)

git ls

List files under version controlgit tar

Create tar file from files under version controlgit commit-now (alias: ’cn’)

Commit with timestamp as messagegit commit-now-push (alias: ’cnp’)

Push after a commit-now

git tree

Show commit history as colored tree structure

Page 209: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Create Custom Commands

Aliases to commands in ∼/.gitconfig, i.e.[alias]

st = statusco = commit

Aliases to functions (you can find these in my config)

git ls

List files under version controlgit tar

Create tar file from files under version controlgit commit-now (alias: ’cn’)

Commit with timestamp as messagegit commit-now-push (alias: ’cnp’)

Push after a commit-now

git tree

Show commit history as colored tree structure

Page 210: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Create Custom Commands

Aliases to commands in ∼/.gitconfig, i.e.[alias]

st = statusco = commit

Aliases to functions (you can find these in my config)

git ls

List files under version controlgit tar

Create tar file from files under version controlgit commit-now (alias: ’cn’)

Commit with timestamp as messagegit commit-now-push (alias: ’cnp’)

Push after a commit-now

git tree

Show commit history as colored tree structure

Page 211: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Create Custom Commands’git tree’ instead of ’git log’

Page 212: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Create Custom Commands’git tree’ instead of ’git log’

Page 213: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Create Custom Commands’git tree’ instead of ’git log’

Page 214: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Create Custom Commands’git tree’ instead of ’git log’

Page 215: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Create Custom Commands’git tree’ instead of ’git log’

Page 216: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Create Custom Commands’git tree’ instead of ’git log’

Page 217: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Create Custom Commands’git vimdiff’ instead of ’git diff’

Page 218: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Create Custom Commands’git vimdiff’ instead of ’git diff’

Page 219: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Create Custom Commands’git vimdiff’ instead of ’git diff’

Page 220: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Create Custom Commands’git vimdiff’ instead of ’git diff’

Page 221: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Create Custom Commands’git vimdiff’ instead of ’git diff’

Page 222: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Create Custom Commands’git vimdiff’ instead of ’git diff’

Page 223: Yet Another GIT Tutorialgdal/scripts/download.php?file=gittutorial.pdfYet Another GIT Tutorial by Giso H. Dal Introduction Architecture CVCS vs DVCS SVN vs GIT Commands Local Repository

Yet AnotherGIT Tutorial

by Giso H. Dal

Introduction

Architecture

CVCS vs DVCS

SVN vs GIT

Commands

Local Repository

Remote Repository

Workflow

Tips andTricks

Questions

Questions?

Email me atgdal at cs.ru.nl

for any further questions.