21
Lecture 8 Integration-Manager Workflow and Rebasing Sign in on the attendance sheet!

Lecture 8 Integration-Manager Workflow and Rebasing · 2018. 5. 3. · $ git checkout -b my-feature $ $ git commit -am "add my feature" Then push your feature

  • Upload
    others

  • View
    15

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Lecture 8 Integration-Manager Workflow and Rebasing · 2018. 5. 3. · $ git checkout -b my-feature $  $ git commit -am "add my feature" Then push your feature

Lecture 8Integration-Manager Workflow and Rebasing

Sign in on the attendance

sheet!

Page 2: Lecture 8 Integration-Manager Workflow and Rebasing · 2018. 5. 3. · $ git checkout -b my-feature $  $ git commit -am "add my feature" Then push your feature

Remember the Centralized Workflow?

Problem: Every developer needs push access to the shared repository!

Page 3: Lecture 8 Integration-Manager Workflow and Rebasing · 2018. 5. 3. · $ git checkout -b my-feature $  $ git commit -am "add my feature" Then push your feature

Integration-Manager Workflow

Local Computer

Github/“The cloud”

Page 4: Lecture 8 Integration-Manager Workflow and Rebasing · 2018. 5. 3. · $ git checkout -b my-feature $  $ git commit -am "add my feature" Then push your feature

Step 1. Fork the public repository

(make your own public copy)

Page 5: Lecture 8 Integration-Manager Workflow and Rebasing · 2018. 5. 3. · $ git checkout -b my-feature $  $ git commit -am "add my feature" Then push your feature

Step 1. Fork the public repository

Blessed Repository

Developer Public

Repository

Page 6: Lecture 8 Integration-Manager Workflow and Rebasing · 2018. 5. 3. · $ git checkout -b my-feature $  $ git commit -am "add my feature" Then push your feature

Step 2. Clone your public repository

$ git clone https://github.com/aperley/Autolab.git

Blessed Repository

Developer Public

Repository

Developer Private

Repository

Page 7: Lecture 8 Integration-Manager Workflow and Rebasing · 2018. 5. 3. · $ git checkout -b my-feature $  $ git commit -am "add my feature" Then push your feature

Step 3. Create a feature branch and make some commits$ git checkout -b my-feature

$ <do some work>

$ git commit -am "add my feature"

Then push your feature branch to your public repository

$ git push origin my-feature

Developer Public

Repository

Developer Private

Repository

Page 8: Lecture 8 Integration-Manager Workflow and Rebasing · 2018. 5. 3. · $ git checkout -b my-feature $  $ git commit -am "add my feature" Then push your feature

Step 4. Create a pull request

Page 9: Lecture 8 Integration-Manager Workflow and Rebasing · 2018. 5. 3. · $ git checkout -b my-feature $  $ git commit -am "add my feature" Then push your feature

The integration manager can inspect and pull in your changes As the integration manager:

$ git remote add aperleys-fork https://github.com/aperley/Autolab.git

$ git checkout aperleys-fork/my-feature

If it looks good:

$ git checkout master

$ git merge aperleys-fork/my-feature

$ git push origin master

Page 10: Lecture 8 Integration-Manager Workflow and Rebasing · 2018. 5. 3. · $ git checkout -b my-feature $  $ git commit -am "add my feature" Then push your feature

The integration manager can inspect and pull in your changes

Developer Public

Repository

Developer Private

Repository

Integration Manager

Repository

Blessed Repository

Page 11: Lecture 8 Integration-Manager Workflow and Rebasing · 2018. 5. 3. · $ git checkout -b my-feature $  $ git commit -am "add my feature" Then push your feature

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 12: Lecture 8 Integration-Manager Workflow and Rebasing · 2018. 5. 3. · $ git checkout -b my-feature $  $ git commit -am "add my feature" Then push your feature

You need to keep your fork up to date

Developer Public

Repository

Developer Private

Repository

Integration Manager

Repository

Blessed Repository

Page 13: Lecture 8 Integration-Manager Workflow and Rebasing · 2018. 5. 3. · $ git checkout -b my-feature $  $ git commit -am "add my feature" Then push your feature

Git Rebase: Squashing Commits

X X ✔

Page 14: Lecture 8 Integration-Manager Workflow and Rebasing · 2018. 5. 3. · $ git checkout -b my-feature $  $ git commit -am "add my feature" Then push your feature

Squashing Commits

Scenario:

Made some commits on a feature branch but want to “clean it up” before making a pull request or merging to master

Page 15: Lecture 8 Integration-Manager Workflow and Rebasing · 2018. 5. 3. · $ git checkout -b my-feature $  $ git commit -am "add my feature" Then push your feature

Squashing Commits

$ git rebase -i master

Begins an interactive rebase of all of the commits since the branch split off of master.

Page 16: Lecture 8 Integration-Manager Workflow and Rebasing · 2018. 5. 3. · $ git checkout -b my-feature $  $ git commit -am "add my feature" Then push your feature

Interactive Rebase

Page 17: Lecture 8 Integration-Manager Workflow and Rebasing · 2018. 5. 3. · $ git checkout -b my-feature $  $ git commit -am "add my feature" Then push your feature

Decide what you want to squash onto the commit above (before)

Page 18: Lecture 8 Integration-Manager Workflow and Rebasing · 2018. 5. 3. · $ git checkout -b my-feature $  $ git commit -am "add my feature" Then push your feature

Now we need to edit the commit message for the first squash group

Page 19: Lecture 8 Integration-Manager Workflow and Rebasing · 2018. 5. 3. · $ git checkout -b my-feature $  $ git commit -am "add my feature" Then push your feature

Same for the second squash group

Page 20: Lecture 8 Integration-Manager Workflow and Rebasing · 2018. 5. 3. · $ git checkout -b my-feature $  $ git commit -am "add my feature" Then push your feature

We are left with a new commit history

Page 21: Lecture 8 Integration-Manager Workflow and Rebasing · 2018. 5. 3. · $ git checkout -b my-feature $  $ git commit -am "add my feature" Then push your feature

What happened?

We rewrote history by replaying the patches for each commit

Base CommitImplement

FeatureBugfix Spelling fix Add tests Fix a test

Base Commit

Implement feature and bugfix and spelling fix

Add tests