Slide 1

Slide 1 text

git rebase by Arturas Smorgun, Inviqa Enlightening Lunch

Slide 2

Slide 2 text

• Git Internal Data Structures; • Interactive Rebase; • Basic Rebase; • Less Basic Rebase; • Use Case. Contents

Slide 3

Slide 3 text

Git Internals Data structures

Slide 4

Slide 4 text

• Content-addressable filesystem; • Insert content -- get key back; • You can add to graph, but not edit or remove. Git

Slide 5

Slide 5 text

• blob -- file contents • tree -- directory layouts and filenames • commit -- forms git commit graph • tag -- annotated tag Objects

Slide 6

Slide 6 text

References • Pointer to an object: • branch • remote branch • lightweight tag

Slide 7

Slide 7 text

Symbolic references • Pointer to another pointer: • HEAD

Slide 8

Slide 8 text

Interactive Rebase

Slide 9

Slide 9 text

$ git rebase -i HEAD~3

Slide 10

Slide 10 text

Interactive • Remove or rearrange commits; • Edit commit messages; • Amend commits; • Squash several commits; • Run shell commands.

Slide 11

Slide 11 text

--autosquash • Used in interactive rebase; • Commits starting with “squash! “ will be automatically marked to squash.

Slide 12

Slide 12 text

Basic Rebase

Slide 13

Slide 13 text

$ git rebase - branch, to which rebasing;

Slide 14

Slide 14 text

git rebase • Forward-port local commits to the updated upstream head (from manual); • One of the ways to integrate changes from one branch to another (from the internets).

Slide 15

Slide 15 text

How it works? • Go to common ancestor; • get diff by each commit of current branch; • save diffs to temporary files; • reset current branch to same commit as branch you rebasing onto; • apply each change in turn.

Slide 16

Slide 16 text

^ say we have this

Slide 17

Slide 17 text

^ $ git rebase master

Slide 18

Slide 18 text

Less Basic Rebase

Slide 19

Slide 19 text

$ git rebase --onto -- branch, to which rebasing; -- ancestor of rebase branch; -- tip of rebase branch;

Slide 20

Slide 20 text

^ say we have this

Slide 21

Slide 21 text

^ after rebase --onto

Slide 22

Slide 22 text

Final Note (instead of conclusion)

Slide 23

Slide 23 text

Do not rebase commits that you have pushed to a public repository.

Slide 24

Slide 24 text

Questions?

Slide 25

Slide 25 text

Thank you! See Inviqa Training “Git Beyond the Basics” by Alistair Stead and “Pro Git” ebook at http://git-scm.com/book by Scot Chacon