lecture 8 rebasing · 2018-05-03 · 1.git checkout –b my-feature git commit –m "e"...

21
Lecture 8 Rebasing Sign in on the attendance sheet!

Upload: others

Post on 21-Jul-2020

13 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Lecture 8 Rebasing · 2018-05-03 · 1.git checkout –b my-feature git commit –m "E" 2.git fetch origin 3.git merge origin/master ewww this sucks! (Sometimes) Need to Get Changes

Lecture 8Rebasing

Sign in on the attendance

sheet!

Page 2: Lecture 8 Rebasing · 2018-05-03 · 1.git checkout –b my-feature git commit –m "E" 2.git fetch origin 3.git merge origin/master ewww this sucks! (Sometimes) Need to Get Changes

Schedule

March 29 Rebasing

April 5 When Things Go Wrong

April 12 Visual Git Tools

April 19 Carnival, no class

April 26 Plumbing and Porcealin

May 3 Final

Page 3: Lecture 8 Rebasing · 2018-05-03 · 1.git checkout –b my-feature git commit –m "E" 2.git fetch origin 3.git merge origin/master ewww this sucks! (Sometimes) Need to Get Changes

Last Time

• Centralized Workflow

• Integration Manager Workflow

Local Computer

Github/“The cloud”

Page 4: Lecture 8 Rebasing · 2018-05-03 · 1.git checkout –b my-feature git commit –m "E" 2.git fetch origin 3.git merge origin/master ewww this sucks! (Sometimes) Need to Get Changes

You need to keep your fork up to date

Developer Public

Repository

Developer Private

Repository

Integration Manager

Repository

Blessed Repository

Page 5: Lecture 8 Rebasing · 2018-05-03 · 1.git checkout –b my-feature git commit –m "E" 2.git fetch origin 3.git merge origin/master ewww this sucks! (Sometimes) Need to Get Changes

You need to keep your fork up to date

In the private developer repo

$ git remote add upstream

https://github.com/autolab/Autolab.git

$ git fetch upstream

$ git checkout master

$ git merge upstream/master

$ git push origin master

Page 6: Lecture 8 Rebasing · 2018-05-03 · 1.git checkout –b my-feature git commit –m "E" 2.git fetch origin 3.git merge origin/master ewww this sucks! (Sometimes) Need to Get Changes

A

B

Ilan’s Computer

origin/master

master

HEAD

(Sometimes) Need to Get Changes from Master into Topic Branch1. Ilan Makes a Bugfix

Page 7: Lecture 8 Rebasing · 2018-05-03 · 1.git checkout –b my-feature git commit –m "E" 2.git fetch origin 3.git merge origin/master ewww this sucks! (Sometimes) Need to Get Changes

A

B

C

Ilan’s Computer

origin/master

1. git fetch origin

master

HEAD

(Sometimes) Need to Get Changes from Master into Topic Branch1. Ilan Makes a Bugfix

Page 8: Lecture 8 Rebasing · 2018-05-03 · 1.git checkout –b my-feature git commit –m "E" 2.git fetch origin 3.git merge origin/master ewww this sucks! (Sometimes) Need to Get Changes

(Sometimes) Need to Get Changes from Master into Topic Branch1. Ilan Makes a Bugfix

A

B

C

Ilan’s Computer

origin/master

1. git fetch origin

2. git merge origin/master

master

HEAD

Page 9: Lecture 8 Rebasing · 2018-05-03 · 1.git checkout –b my-feature git commit –m "E" 2.git fetch origin 3.git merge origin/master ewww this sucks! (Sometimes) Need to Get Changes

(Sometimes) Need to Get Changes from Master into Topic Branch1. Ilan Makes a Bugfix

A

B

C

Ilan’s Computer

1. git fetch origin

2. git merge origin/master

master

HEAD

origin/master

Page 10: Lecture 8 Rebasing · 2018-05-03 · 1.git checkout –b my-feature git commit –m "E" 2.git fetch origin 3.git merge origin/master ewww this sucks! (Sometimes) Need to Get Changes

(Sometimes) Need to Get Changes from Master into Topic Branch1. Ilan Makes a Bugfix

A

B

C

Ilan’s Computer

1. git fetch origin

2. git merge origin/master

3. git checkout –b bugfixgit commit –m "D"

master

origin/master

D

HEAD

bugfix

Page 11: Lecture 8 Rebasing · 2018-05-03 · 1.git checkout –b my-feature git commit –m "E" 2.git fetch origin 3.git merge origin/master ewww this sucks! (Sometimes) Need to Get Changes

(Sometimes) Need to Get Changes from Master into Topic Branch1. Ilan Makes a Bugfix

A

B

C

Ilan’s Computer

1. git fetch origin

2. git merge origin/master

3. git checkout –b bugfixgit commit –m "D“

4. git checkout mastergit merge bugfixorigin/master

D

HEAD

bugfix

master

Page 12: Lecture 8 Rebasing · 2018-05-03 · 1.git checkout –b my-feature git commit –m "E" 2.git fetch origin 3.git merge origin/master ewww this sucks! (Sometimes) Need to Get Changes

(Sometimes) Need to Get Changes from Master into Topic Branch1. Ilan Makes a Bugfix

A

B

C

Ilan’s Computer

1. git fetch origin

2. git merge origin/master

3. git checkout –b bugfixgit commit –m "D“

4. git checkout mastergit merge bugfix

5. git push origin master

D

HEAD

bugfix

master

origin/master

Page 13: Lecture 8 Rebasing · 2018-05-03 · 1.git checkout –b my-feature git commit –m "E" 2.git fetch origin 3.git merge origin/master ewww this sucks! (Sometimes) Need to Get Changes

Aaron’s Computer

(Sometimes) Need to Get Changes from Master into Topic Branch2. Aaron is working on a feature

A

B

C origin/master

master

HEAD

Page 14: Lecture 8 Rebasing · 2018-05-03 · 1.git checkout –b my-feature git commit –m "E" 2.git fetch origin 3.git merge origin/master ewww this sucks! (Sometimes) Need to Get Changes

Aaron’s Computer

1. git checkout –b my-featuregit commit –m "E"

(Sometimes) Need to Get Changes from Master into Topic Branch2. Aaron is working on a feature

A

B

C origin/master

my-feature

HEAD

E

master

Page 15: Lecture 8 Rebasing · 2018-05-03 · 1.git checkout –b my-feature git commit –m "E" 2.git fetch origin 3.git merge origin/master ewww this sucks! (Sometimes) Need to Get Changes

Aaron’s Computer

1. git checkout –b my-featuregit commit –m "E"

2. git fetch origin

(Sometimes) Need to Get Changes from Master into Topic Branch2. Aaron is working on a feature

A

B

C

E

master

D origin/master

my-feature

HEAD

Page 16: Lecture 8 Rebasing · 2018-05-03 · 1.git checkout –b my-feature git commit –m "E" 2.git fetch origin 3.git merge origin/master ewww this sucks! (Sometimes) Need to Get Changes

Aaron’s Computer

1. git checkout –b my-featuregit commit –m "E"

2. git fetch origin

3. git merge origin/master

ewww this sucks!

(Sometimes) Need to Get Changes from Master into Topic Branch2. Aaron is working on a feature

A

B

C

my-feat HEAD

E

master

D origin/master

F

Page 17: Lecture 8 Rebasing · 2018-05-03 · 1.git checkout –b my-feature git commit –m "E" 2.git fetch origin 3.git merge origin/master ewww this sucks! (Sometimes) Need to Get Changes

Aaron’s Computer

much cleaner!

E' is the same as E but with a different parent

(Sometimes) Need to Get Changes from Master into Topic Branch2. Aaron is working on a feature

A

B

C

my-feat HEAD

E

master

D origin/master

origin/master

E'

Page 18: Lecture 8 Rebasing · 2018-05-03 · 1.git checkout –b my-feature git commit –m "E" 2.git fetch origin 3.git merge origin/master ewww this sucks! (Sometimes) Need to Get Changes

Rebasing

• Rebasing rewrites your git history, replaying the diffs of your commits

• Useful as an alternative to merging when you want to keep history neat

Page 19: Lecture 8 Rebasing · 2018-05-03 · 1.git checkout –b my-feature git commit –m "E" 2.git fetch origin 3.git merge origin/master ewww this sucks! (Sometimes) Need to Get Changes

Aaron’s Computer

1. git checkout –b my-featuregit commit –m "E"

2. git fetch origin

(Sometimes) Need to Get Changes from Master into Topic Branch2. Aaron is working on a feature

A

B

C

E

master

D origin/master

my-feature

HEAD

Page 20: Lecture 8 Rebasing · 2018-05-03 · 1.git checkout –b my-feature git commit –m "E" 2.git fetch origin 3.git merge origin/master ewww this sucks! (Sometimes) Need to Get Changes

Aaron’s Computer

1. git checkout –b my-featuregit commit –m "E"

2. git fetch origin

3. git rebase origin/master

(Sometimes) Need to Get Changes from Master into Topic Branch2. Aaron is working on a feature

A

B

C

E'

master

D origin/master

my-feature HEAD

Page 21: Lecture 8 Rebasing · 2018-05-03 · 1.git checkout –b my-feature git commit –m "E" 2.git fetch origin 3.git merge origin/master ewww this sucks! (Sometimes) Need to Get Changes

Activity/Homework

Rebase the changes you made a PR for last week on top of the new upstream/master and push to your branch. Your PR should update automatically.

push -f (force push)