1 of 175

2 of 175

2

CS61B, Spring 2025 @ UC Berkeley

Industry Practices for Collaboration

Software Engineering II

Lecture 31

3 of 175

Stella Kaval (she/her)

  • 4th year, Computer Science
  • 4th semester on CS61B staff
  • Prev. intern at Microsoft, Oracle
  • Favorite Taylor Swift album: Reputation

Kanav Mittal (he/him)

  • 4th year, EECS
  • 3rd semester on CS61B staff
  • Prev. intern at a data privacy startup then at NVIDIA
  • Favorite Taylor Swift album: Folklore

4 of 175

Introduction

Lecture 31, CS61B Spring 2025

Introduction

Agile Development

Review: Git Commands

Git Branching and Merging

Pull Requests

Summary

5 of 175

What comes to mind when you think about a software engineer’s day to day work?

6 of 175

Myth: Software engineering is mostly coding by yourself

7 of 175

Collaboration

Customers

Engineers

Past and future employees

Product managers, designers

You

8 of 175

Introduction to collaboration in software engineering: open office

9 of 175

Introduction to collaboration in software engineering: open office

Advantages

  • Efficient collaboration
  • Spontaneous conversations

Disadvantages

  • Only works in real time
  • Remote work

Today’s topics

  • Agile framework at a larger scale
  • Git to collaborate with teammates

10 of 175

Agile Development

Lecture 31, CS61B Spring 2025

Introduction

Agile Development

Review: Git Commands

Git Branching and Merging

Pull Requests

Summary

11 of 175

Collaborative Project

Name

  • 61Belly

Purpose

  • Rating foods and sharing culinary opinions

Key Features

  • User reviews
  • Numerical rating system
  • Photo uploads
  • Social sharing

12 of 175

Talking to Customers

Why Customer Input Matters

  • Ensures product-market fit
  • Identifies real user needs and pain points
  • Reduces risk of developing unwanted features

Questions

  • What features would you find most useful in a food rating app?
  • How often do you use food rating apps, and why?
  • What frustrates you about existing food rating platforms?

13 of 175

Findings

Top user suggestions

  • Easy registration
  • Customizable profile
  • Reviews and ratings system
  • High-quality photos
  • Search and filter options for the menu
  • Social sharing capabilities

Any class suggestions?

14 of 175

Next Steps

Given our findings, now what?

  • How do we plan building out our app?
  • How do we adapt to changing customer needs?
  • How will we work together with limited time, how about asynchronously?

15 of 175

Agile Software Development Review

“Iterative approach to delivering a project, which focuses on continuous releases that incorporate customer feedback” (Atlassian)

Set of values that guide software development processes through 4 principles:

16 of 175

Agile Software Development Review

“Iterative approach to delivering a project, which focuses on continuous releases that incorporate customer feedback” (Atlassian)

Set of values that guide software development processes through 4 principles:

Individuals and interactions

Working software

Customer collaboration

Responding to change

17 of 175

Agile Development

Scrum is an Agile framework for managing work

Product Backlog List of tasks from the product roadmap, written as user stories

Sprint Backlog Project broken into pieces called “sprints”

Sprint

1-4 weeks to complete an iteration, with a daily stand-up

Working increment of the product

18 of 175

Applying Agile to 61Belly

Product Backlog

  1. Easy registration
  2. Reviews and ratings system
  3. Search and filter options for menu
  4. Social sharing capabilities
  5. Customizable profile
  6. High-quality photos
  7. Edit reviews after they’re posted
  8. Create shared ratings with friends
  9. Push notifications

Sprint 1: 4/11 → 4/25

Sprint 2: 4/25 → 5/1

Sprint 3: 5/1 → 5/15

19 of 175

Applying Agile to 61Belly

Product Backlog

  • Search and filter options for menu
  • Social sharing capabilities
  • Customizable profile
  • High-quality photos
  • Edit reviews after they’re posted
  • Create shared ratings with friends
  • Push notifications
  • Easy registration
  • Reviews and ratings system

Sprint 1: 4/11 → 4/25

Sprint 2: 4/25 → 5/1

Sprint 3: 5/1 → 5/15

20 of 175

Applying Agile to 61Belly

Product Backlog

  • Customizable profile
  • High-quality photos
  • Edit reviews after they’re posted
  • Create shared ratings with friends
  • Push notifications
  • Easy registration
  • Reviews and ratings system
  • Search and filter options for menu
  • Social sharing capabilities

Sprint 1: 4/11 → 4/25

Sprint 2: 4/25 → 5/1

Sprint 3: 5/1 → 5/15

21 of 175

Applying Agile to 61Belly

Product Backlog

  • Edit reviews after they’re posted
  • Create shared ratings with friends
  • Push notifications
  • Easy registration
  • Reviews and ratings system
  • Search and filter options for menu
  • Social sharing capabilities
  • Customizable profile
  • High-quality photos

Sprint 1: 4/11 → 4/25

Sprint 2: 4/25 → 5/1

Sprint 3: 5/1 → 5/15

22 of 175

Agile Development Tools

What tools do software engineers use to track and put these plans into action?

Jira is a software application developed by Atlassian for issue tracking and project management

  • Sprint planning and tracking
  • Customizable workflows and boards
  • Backlog management
  • Reporting and dashboards

Let’s create a Jira project for 61Belly!

23 of 175

Jira Demo

24 of 175

Jira Demo

A Jira ticket is a task, bug, or request within a project

25 of 175

Jira Demo

26 of 175

Jira Demo

27 of 175

Jira Demo

28 of 175

Jira Demo

29 of 175

Jira Demo

30 of 175

Jira Demo

31 of 175

Developing features and collaboration

Why do we use Jira? It helps communicate:

  • Who will be doing which task
  • When the tasks can be completed by
  • How to adjust timelines to incorporate customer feedback

32 of 175

Developing features and collaboration

Why do we use Jira? It helps communicate:

  • Who will be doing which task
  • When the tasks can be completed by
  • How to adjust timelines to incorporate customer feedback

We talked about completing these tickets in the backlog on a high level, but how do we actually code them?

  • Collaborate with developers (co-workers, future ones, yourself)
  • See changes over time
  • Revert to previous versions

33 of 175

Solution 1: Google Docs

Google Docs is great at working together on documents

  • Easy-to-use
  • Allows for real time collaboration
  • Maintains a version history of documents so you can go back
  • So… what’s the problem?

34 of 175

Git is more powerful!

Advantages

  • Git allows you to choose files and when to take a snapshot of your files to include in your version history
  • Git allows you to collaborate on different variations of your project without interference from the others
    • e.g. partners working on different Project 3B ambition features
    • You don’t want errors from one variation affecting the other variation

Disadvantages

  • Git is a more specialized tool for software development and not as helpful for non-developers

35 of 175

Review: Git Commands

Lecture 31, CS61B Spring 2025

Introduction

Agile Development

Review: Git Commands

Git Branching and Merging

Pull Requests

Summary

36 of 175

Git as a version control system

  • Committing is like a stronger type of saving
    • Saves a snapshot of your files
    • You can go back to this snapshot if you would like

37 of 175

Git as a version control system

  • Committing is like a stronger type of saving
    • Saves a snapshot of your files
    • You can go back to this snapshot if you would like

working directory

38 of 175

Git as a version control system

  • Committing is like a stronger type of saving
    • Saves a snapshot of your files
    • You can go back to this snapshot if you would like
  • git add tells Git which files to save (i.e., files in staging area)

working directory

staging area

add

39 of 175

Git as a version control system

  • Committing is like a stronger type of saving
    • Saves a snapshot of your files
    • You can go back to this snapshot if you would like
  • git add tells Git which files to save (i.e., files in staging area)
  • git commit executes the save
    • Adds commit to version history in your local repository

working directory

staging area

local repo (.git folder)

add

commit

40 of 175

Git as a version control system

  • Committing is like a stronger type of saving
    • Saves a snapshot of your files
    • You can go back to this snapshot if you would like
  • git add tells Git which files to save (i.e., files in staging area)
  • git commit executes the save
    • Adds commit to version history in your local repository
  • git push sends your updated version history to a remote repository for backup
    • Remote repository: copy of your code stored on Internet

working directory

staging area

local repo (.git folder)

remote repo

add

commit

push

41 of 175

Commit History

  • Commits contain pointers to the commits that came before them

58bc8a

Create Restaurant class

6af3e2

Initial commit

42 of 175

Commit History

  • Commits contain pointers to the commits that came before them

58bc8a

Create Restaurant class

6af3e2

Initial commit

Commit ID

Commit message

43 of 175

Commit History

  • Commits contain pointers to the commits that came before them
    • Commit history forms a linked list

58bc8a

Create Restaurant class

6af3e2

Initial commit

44 of 175

Commit History

  • Commits contain pointers to the commits that came before them
    • Commit history forms a linked list
    • When we make a commit, we add a new node to our linked list

58bc8a

Create Restaurant class

7126fd

Added getRating method to Restaurant

6af3e2

Initial commit

45 of 175

Commit History

  • Commits contain pointers to the commits that came before them
    • Commit history forms a linked list
    • When we make a commit, we add a new node to our linked list

  • git log gives you the commit history

58bc8a

Create Restaurant class

7126fd

Added getRating method to Restaurant

6af3e2

Initial commit

46 of 175

Commit History

  • Commits contain pointers to the commits that came before them
    • Commit history forms a linked list
    • When we make a commit, we add a new node to our linked list

  • git log gives you the commit history
    • Starting from current commit, keep iterating through the previous commits until you reach the initial commit

58bc8a

Create Restaurant class

7126fd

Added getRating method to Restaurant

6af3e2

Initial commit

47 of 175

Commit History

  • Commits contain pointers to the commits that came before them
    • Commit history forms a linked list
    • When we make a commit, we add a new node to our linked list

  • git log gives you the commit history
    • Starting from current commit, keep iterating through the previous commits until you reach the initial commit
    • What are all the changes that occurred to get the current code?

58bc8a

Create Restaurant class

7126fd

Added getRating method to Restaurant

6af3e2

Initial commit

48 of 175

Going back to a previous version of your code

  • Why do we care about storing a version history?
    • What if you break something in your code and want to go back?
    • Or what if you want to build off a past checkpoint of your code?

49 of 175

Going back to a previous version of your code

  • Why do we care about storing a version history?
    • What if you break something in your code and want to go back?
    • Or what if you want to build off a past checkpoint of your code?
  • Git allows you to go back to a previous version of your code saved in your commit history
    • See a history and get commit ID using git log
    • Inspect past version with git checkout
    • Undo changes with git revert or git reset

50 of 175

Going back to a previous version of your code

  • Why do we care about storing a version history?
    • What if you break something in your code and want to go back?
    • Or what if you want to build off a past checkpoint of your code?
  • Git allows you to go back to a previous version of your code saved in your commit history
    • See a history and get commit ID using git log
    • Inspect past version with git checkout
    • Undo changes with git revert or git reset

6af3e2

58bc8a

7126fd

ffc831

7500af

b7f4e1

1072f1

51 of 175

Going back to a previous version of your code

  • Why do we care about storing a version history?
    • What if you break something in your code and want to go back?
    • Or what if you want to build off a past checkpoint of your code?
  • Git allows you to go back to a previous version of your code saved in your commit history
    • See a history and get commit ID using git log
    • Inspect past version with git checkout
    • Undo changes with git revert or git reset
  • Tips
    • Write brief but descriptive commit messages
    • Commit frequently!

52 of 175

Git as a tool for collaboration

  • Remote repositories can be shared by multiple people

Stella’s local repository

Kanav’s local repository

53 of 175

Git as a tool for collaboration

  • Remote repositories can be shared by multiple people
  • git push updates the remote with your local changes

Stella’s local repository

Kanav’s local repository

git push

git push

54 of 175

Git as a tool for collaboration

  • Remote repositories can be shared by multiple people
  • git push updates the remote with your local changes
  • git pull incorporates changes from remote into local

Stella’s local repository

Kanav’s local repository

git pull

git pull

git push

git push

55 of 175

Git as a tool for collaboration

  • Remote repositories can be shared by multiple people
  • git push updates the remote with your local changes
  • git pull incorporates changes from remote into local
  • One developer can push their changes, and the other developer can pull them in to work off them.

Stella’s local repository

Kanav’s local repository

git pull

git pull

git push

git push

56 of 175

Git as a tool for collaboration

  • Remote repositories can be shared by multiple people
  • git push updates the remote with your local changes
  • git pull incorporates changes from remote into local
  • One developer can push their changes, and the other developer can pull them in to work off them.
  • Remember to pull before pushing

Stella’s local repository

Kanav’s local repository

git pull

git pull

git push

git push

57 of 175

Collaborating on the same commit history

  • Remember: commit history forms a linked list-like structure

58 of 175

Collaborating on the same commit history

  • Remember: commit history forms a linked list-like structure
  • git push and git pull try to copy this linked list of commits back and forth between local and remote repositories
    • Multiple people can work on the same line of development

59 of 175

Collaborating on the same commit history

Stella

Kanav

60 of 175

Collaborating on the same commit history

Stella creates a Restaurant class and commits it

58bc8a

Stella: Create Restaurant class

Stella

Kanav

61 of 175

Collaborating on the same commit history

Stella pushes her changes to GitHub so others can access them

58bc8a

Stella: Create Restaurant class

Stella

58bc8a

Stella: Create Restaurant class

Kanav

62 of 175

Collaborating on the same commit history

Kanav pulls Stella’s changes from GitHub

58bc8a

Stella: Create Restaurant class

Stella

58bc8a

Stella: Create Restaurant class

Kanav

58bc8a

Stella: Create Restaurant class

63 of 175

Collaborating on the same commit history

Kanav works on creating a Cafe subclass and commits it

58bc8a

Stella: Create Restaurant class

Stella

58bc8a

Stella: Create Restaurant class

Kanav

58bc8a

Stella: Create Restaurant class

8a6de7

Kanav: Created Cafe subclass

64 of 175

Collaborating on the same commit history

Kanav pushes his commit history to GitHub

58bc8a

Stella: Create Restaurant class

Stella

58bc8a

Stella: Create Restaurant class

Kanav

58bc8a

Stella: Create Restaurant class

8a6de7

Kanav: Created Cafe subclass

8a6de7

Kanav: Created Cafe subclass

65 of 175

Collaborating on the same commit history

Stella pulls the commit history from GitHub. Her commit history is fast-forwarded to match the remote’s.

58bc8a

Stella: Create Restaurant class

Stella

58bc8a

Stella: Create Restaurant class

Kanav

58bc8a

Stella: Create Restaurant class

8a6de7

Kanav: Created Cafe subclass

8a6de7

Kanav: Created Cafe subclass

8a6de7

Kanav: Created Cafe subclass

66 of 175

Collaborating on the same commit history

Stella works on adding text reviews to Restaurant.java

58bc8a

Stella: Create Restaurant class

Stella

58bc8a

Stella: Create Restaurant class

Kanav

58bc8a

Stella: Create Restaurant class

8a6de7

Kanav: Created Cafe subclass

8a6de7

Kanav: Created Cafe subclass

8a6de7

Kanav: Created Cafe subclass

4f8e44

Stella: Added text reviews to Restaurant

67 of 175

Collaborating on the same commit history

Kanav works on adding a coffee ranking feature to Cafe.java

58bc8a

Stella: Create Restaurant class

Stella

58bc8a

Stella: Create Restaurant class

Kanav

58bc8a

Stella: Create Restaurant class

8a6de7

Kanav: Created Cafe subclass

8a6de7

Kanav: Created Cafe subclass

8a6de7

Kanav: Created Cafe subclass

cf3780

Kanav: Added coffee ranking to Cafe.java

4f8e44

Stella: Added text reviews to Restaurant

68 of 175

Collaborating on the same commit history

Stella pushes her work to GitHub

58bc8a

Stella: Create Restaurant class

Stella

58bc8a

Stella: Create Restaurant class

Kanav

58bc8a

Stella: Create Restaurant class

8a6de7

Kanav: Created Cafe subclass

8a6de7

Kanav: Created Cafe subclass

8a6de7

Kanav: Created Cafe subclass

4f8e44

Stella: Added text reviews to Restaurant

cf3780

Kanav: Added coffee ranking to Cafe.java

4f8e44

Stella: Added text reviews to Restaurant

69 of 175

Collaborating on the same commit history

Kanav wants to push to GitHub, but first he tries to pull from GitHub…

58bc8a

Stella: Create Restaurant class

Stella

58bc8a

Stella: Create Restaurant class

Kanav

58bc8a

Stella: Create Restaurant class

8a6de7

Kanav: Created Cafe subclass

8a6de7

Kanav: Created Cafe subclass

8a6de7

Kanav: Created Cafe subclass

4f8e44

Stella: Added text reviews to Restaurant

cf3780

Kanav: Added coffee ranking to Cafe.java

4f8e44

Stella: Added text reviews to Restaurant

70 of 175

Collaborating on the same commit history

Kanav tries to pull from GitHub, but he now finds that the remote’s history diverges from his

58bc8a

Stella: Create Restaurant class

Stella

58bc8a

Stella: Create Restaurant class

Kanav

58bc8a

Stella: Create Restaurant class

8a6de7

Kanav: Created Cafe subclass

8a6de7

Kanav: Created Cafe subclass

8a6de7

Kanav: Created Cafe subclass

4f8e44

Stella: Added text reviews to Restaurant

cf3780

Kanav: Added coffee ranking to Cafe.java

4f8e44

Stella: Added text reviews to Restaurant

71 of 175

Merging

  • If the remote and local commit histories at one point shared a common ancestor commit but have since then gone their own way, we say that the two histories diverge from each other

72 of 175

Merging

  • If the remote and local commit histories at one point shared a common ancestor commit but have since then gone their own way, we say that the two histories diverge from each other
  • Solution: merge the remote and local commit history together
    • We add a merge commit to signify the merge

73 of 175

Merging

  • If the remote and local commit histories at one point shared a common ancestor commit but have since then gone their own way, we say that the two histories diverge from each other
  • Solution: merge the remote and local commit history together
    • We add a merge commit to signify the merge
  • The merge finds the Closest Common Ancestor (point of divergence) of the two histories
    • Combines the changes made from the closest common ancestor to each of the latest commits

74 of 175

Merging

If you’ve seen a message like this, this is executing a merge

75 of 175

Collaborating on the same commit history

Kanav tries to pull from GitHub, but he now finds that the remote’s history diverges from his

58bc8a

Stella: Create Restaurant class

Stella

58bc8a

Stella: Create Restaurant class

Kanav

58bc8a

Stella: Create Restaurant class

8a6de7

Kanav: Created Cafe subclass

8a6de7

Kanav: Created Cafe subclass

8a6de7

Kanav: Created Cafe subclass

4f8e44

Stella: Added text reviews to Restaurant

cf3780

Kanav: Added coffee ranking to Cafe.java

4f8e44

Stella: Added text reviews to Restaurant

76 of 175

Collaborating on the same commit history

First step of the merge: identify the closest common ancestor

58bc8a

Stella: Create Restaurant class

Kanav

58bc8a

Stella: Create Restaurant class

8a6de7

Kanav: Created Cafe subclass

8a6de7

Kanav: Created Cafe subclass

cf3780

Kanav: Added coffee ranking to Cafe.java

4f8e44

Stella: Added text reviews to Restaurant

closest common ancestor

77 of 175

Collaborating on the same commit history

Second step of the merge: combine changes and add a merge commit

58bc8a

Stella: Create Restaurant class

Kanav

58bc8a

Stella: Create Restaurant class

8a6de7

Kanav: Created Cafe subclass

8a6de7

Kanav: Created Cafe subclass

cf3780

Kanav: Added coffee ranking to Cafe.java

4f8e44

Stella: Added text reviews to Restaurant

closest common ancestor

Edited Restaurant.java

Edited

Cafe.java

78 of 175

Collaborating on the same commit history

Second step of the merge: combine changes and add a merge commit

58bc8a

Stella: Create Restaurant class

Stella

58bc8a

Stella: Create Restaurant class

Kanav

58bc8a

Stella: Create Restaurant class

8a6de7

Kanav: Created Cafe subclass

8a6de7

Kanav: Created Cafe subclass

8a6de7

Kanav: Created Cafe subclass

4f8e44

Stella: Added text reviews to Restaurant

4f8e44

Stella: Added text reviews to Restaurant

d90e17

Kanav: merge commit

4f8e44

Stella: Added text reviews to Restaurant

cf3780

Kanav: Added coffee ranking to Cafe.java

79 of 175

Collaborating on the same commit history

Kanav pushes his commit history

58bc8a

Stella: Create Restaurant class

Stella

58bc8a

Stella: Create Restaurant class

Kanav

58bc8a

Stella: Create Restaurant class

8a6de7

Kanav: Created Cafe subclass

8a6de7

Kanav: Created Cafe subclass

8a6de7

Kanav: Created Cafe subclass

4f8e44

Stella: Added text reviews to Restaurant

4f8e44

Stella: Added text reviews to Restaurant

d90e17

Kanav: merge commit

4f8e44

Stella: Added text reviews to Restaurant

cf3780

Kanav: Added coffee ranking to Cafe.java

d90e17

Kanav: merge commit

cf3780

Kanav: Added coffee ranking to Cafe.java

80 of 175

Collaborating on the same commit history

Kanav edits Restaurant.java to add photos to reviews and makes a commit

Stella

Kanav

4f8e44

Stella: Added text reviews to Restaurant

4f8e44

Stella: Added text reviews to Restaurant

d90e17

Kanav: merge commit

4f8e44

Stella: Added text reviews to Restaurant

cf3780

Kanav: Added coffee ranking to Cafe.java

e3abc2

Kanav: Added photos to reviews in Restaurant

d90e17

Kanav: merge commit

cf3780

Kanav: Added coffee ranking to Cafe.java

81 of 175

Collaborating on the same commit history

Kanav pushes his changes to GitHub

Stella

Kanav

4f8e44

Stella: Added text reviews to Restaurant

4f8e44

Stella: Added text reviews to Restaurant

d90e17

Kanav: merge commit

4f8e44

Stella: Added text reviews to Restaurant

cf3780

Kanav: Added coffee ranking to Cafe.java

e3abc2

Kanav: Added photos to reviews in Restaurant

d90e17

Kanav: merge commit

cf3780

Kanav: Added coffee ranking to Cafe.java

e3abc2

Kanav: Added photos to reviews in Restaurant

82 of 175

Collaborating on the same commit history

Stella edits Restaurant.java to add star ratings to reviews and makes a commit

Stella

Kanav

4f8e44

Stella: Added text reviews to Restaurant

4f8e44

Stella: Added text reviews to Restaurant

d90e17

Kanav: merge commit

4f8e44

Stella: Added text reviews to Restaurant

cf3780

Kanav: Added coffee ranking to Cafe.java

e3abc2

Kanav: Added photos to reviews in Restaurant

d90e17

Kanav: merge commit

cf3780

Kanav: Added coffee ranking to Cafe.java

e3abc2

Kanav: Added photos to reviews in Restaurant

be478a

Stella: Added ratings to Restaurant

83 of 175

Collaborating on the same commit history

Stella wants to push her changes to GitHub, but…

Stella

Kanav

4f8e44

Stella: Added text reviews to Restaurant

4f8e44

Stella: Added text reviews to Restaurant

d90e17

Kanav: merge commit

4f8e44

Stella: Added text reviews to Restaurant

cf3780

Kanav: Added coffee ranking to Cafe.java

e3abc2

Kanav: Added photos to reviews in Restaurant

d90e17

Kanav: merge commit

cf3780

Kanav: Added coffee ranking to Cafe.java

e3abc2

Kanav: Added photos to reviews in Restaurant

be478a

Stella: Added ratings to Restaurant

84 of 175

Collaborating on the same commit history

Stella wants to push her changes to GitHub, but she first pulls (pull before push!)

Stella

Kanav

4f8e44

Stella: Added text reviews to Restaurant

4f8e44

Stella: Added text reviews to Restaurant

d90e17

Kanav: merge commit

4f8e44

Stella: Added text reviews to Restaurant

cf3780

Kanav: Added coffee ranking to Cafe.java

e3abc2

Kanav: Added photos to reviews in Restaurant

d90e17

Kanav: merge commit

cf3780

Kanav: Added coffee ranking to Cafe.java

e3abc2

Kanav: Added photos to reviews in Restaurant

be478a

Stella: Added ratings to Restaurant

85 of 175

Collaborating on the same commit history

Stella pulls from GitHub, but local and remote histories diverge.

Stella

Kanav

4f8e44

Stella: Added text reviews to Restaurant

4f8e44

Stella: Added text reviews to Restaurant

d90e17

Kanav: merge commit

4f8e44

Stella: Added text reviews to Restaurant

cf3780

Kanav: Added coffee ranking to Cafe.java

e3abc2

Kanav: Added photos to reviews in Restaurant

d90e17

Kanav: merge commit

cf3780

Kanav: Added coffee ranking to Cafe.java

e3abc2

Kanav: Added photos to reviews in Restaurant

be478a

Stella: Added ratings to Restaurant

86 of 175

Collaborating on the same commit history

Step 1: Git identifies Closest Common Ancestor

Stella

Kanav

4f8e44

Stella: Added text reviews to Restaurant

4f8e44

Stella: Added text reviews to Restaurant

d90e17

Kanav: merge commit

4f8e44

Stella: Added text reviews to Restaurant

cf3780

Kanav: Added coffee ranking to Cafe.java

e3abc2

Kanav: Added photos to reviews in Restaurant

d90e17

Kanav: merge commit

cf3780

Kanav: Added coffee ranking to Cafe.java

e3abc2

Kanav: Added photos to reviews in Restaurant

be478a

Stella: Added ratings to Restaurant

87 of 175

Collaborating on the same commit history

Step 2: Combine changes from the Closest Common Ancestor to the latest commits of the histories

Stella

Kanav

4f8e44

Stella: Added text reviews to Restaurant

4f8e44

Stella: Added text reviews to Restaurant

d90e17

Kanav: merge commit

4f8e44

Stella: Added text reviews to Restaurant

cf3780

Kanav: Added coffee ranking to Cafe.java

e3abc2

Kanav: Added photos to reviews in Restaurant

d90e17

Kanav: merge commit

cf3780

Kanav: Added coffee ranking to Cafe.java

e3abc2

Kanav: Added photos to reviews in Restaurant

be478a

Stella: Added ratings to Restaurant

88 of 175

Collaborating on the same commit history

Step 2: Combine changes made from Closest Common Ancestor to latest commits of the histories

Stella

Kanav

4f8e44

Stella: Added text reviews to Restaurant

4f8e44

Stella: Added text reviews to Restaurant

d90e17

Kanav: merge commit

4f8e44

Stella: Added text reviews to Restaurant

cf3780

Kanav: Added coffee ranking to Cafe.java

e3abc2

Kanav: Added photos to reviews in Restaurant

d90e17

Kanav: merge commit

cf3780

Kanav: Added coffee ranking to Cafe.java

e3abc2

Kanav: Added photos to reviews in Restaurant

be478a

Stella: Added ratings to Restaurant

Restaurant.java edited

Restaurant.java edited

89 of 175

Merge conflicts

  • If both histories modified the same file in different ways, which version do we use in our merge commit?
    • Git cannot automatically compute the merge
    • Answer: let the developer decide by resolving a merge conflict

90 of 175

Merge conflicts

  • If both histories modified the same file in different ways, which version do we use in our merge commit?
    • Git cannot automatically compute the merge
    • Answer: let the developer decide by resolving a merge conflict

public class Restaurant {

<<<<<<< HEAD

private int[] ratings;

public Restaurant (int[] ratings) {

this.ratings = ratings;

=======

private Photo[] photos;

public Restaurant (Photo[] photos) {

this.photos = photos

>>>>>>> e3abc2

}

}

91 of 175

Merge conflicts

  • If both histories modified the same file in different ways, which version do we use in our merge commit?
    • Git cannot automatically compute the merge
    • Answer: let the developer decide by resolving a merge conflict

public class Restaurant {

<<<<<<< HEAD

private int[] ratings;

public Restaurant (int[] ratings) {

this.ratings = ratings;

=======

private Photo[] photos;

public Restaurant (Photo[] photos) {

this.photos = photos

>>>>>>> e3abc2

}

}

Local version

92 of 175

Merge conflicts

  • If both histories modified the same file in different ways, which version do we use in our merge commit?
    • Git cannot automatically compute the merge
    • Answer: let the developer decide by resolving a merge conflict

public class Restaurant {

<<<<<<< HEAD

private int[] ratings;

public Restaurant (int[] ratings) {

this.ratings = ratings;

=======

private Photo[] photos;

public Restaurant (Photo[] photos) {

this.photos = photos

>>>>>>> e3abc2

}

}

Local version

Remote version

93 of 175

Merge conflicts

  • If both histories modified the same file in different ways, which version do we use in our merge commit?
    • Git cannot automatically compute the merge
    • Answer: let the developer decide by resolving a merge conflict
  • Resolve merge conflicts by choosing the correct version (or combining parts of both) and removing all the extra text. Test, then, finish the commit with git commit

public class Restaurant {

<<<<<<< HEAD

private int[] ratings;

public Restaurant (int[] ratings) {

this.ratings = ratings;

=======

private Photo[] photos;

public Restaurant (Photo[] photos) {

this.photos = photos

>>>>>>> e3abc2

}

}

Local version

Remote version

94 of 175

Merge conflicts are messy!

  • Merge conflicts require a lot of manual work
  • Occur when we have multiple developers editing same file in different ways
    • Almost inevitable!

95 of 175

Merge conflicts are messy!

  • Merge conflicts require a lot of manual work
  • Occur when we have multiple developers editing same file in different ways
    • Almost inevitable!
  • Can we reduce the frequency of merges and merge conflicts?

96 of 175

Merge conflicts are messy!

  • Merge conflicts require a lot of manual work
  • Occur when we have multiple developers editing same file in different ways
    • Almost inevitable!
  • Can we reduce the frequency of merges and merge conflicts?
  • Can we let developers edit files independently and then only merge when necessary?

97 of 175

Solution 1: Just push and pull less

  • Can we let developers edit files independently and then only merge when necessary?
  • Solution: push and pull only when you have completed a feature.

98 of 175

Solution 1: Just push and pull less

  • Can we let developers edit files independently and then only merge when necessary?
  • Solution: push and pull only when you have completed a feature.
  • But…what if two people wanted to work on the same feature together?
    • We need pushing and pulling to work off each others’ changes

99 of 175

From linear to branches

  • With a linked list linear commit history, everyone adds their commits to the same line of development
    • This means that your changes will affect your collaborators’ changes
    • Can we isolate changes from each other until they’re ready?

100 of 175

From linear to branches

  • With a linked list linear commit history, everyone adds their commits to the same line of development
    • This means that your changes will affect your collaborators’ changes
    • Can we isolate changes from each other until they’re ready?
  • Solution: we can create other lines of development (branches)
    • Developers can work independently on in-progress features without interference from other features
    • This may be useful for ambition features in Project 3B

101 of 175

Git Branching and Merging

Lecture 31, CS61B Spring 2025

Introduction

Agile Development

Review: Git Commands

Git Branching and Merging

Pull Requests

Summary

102 of 175

Branches

  • Branches are pointers to commits
    • Generally, they point to the latest commit in a line of development

103 of 175

Branches

  • Branches are pointers to commits
    • Generally, they point to the latest commit in a line of development
  • Can create new branches with git branch <branch-name>

104 of 175

Branches

  • Branches are pointers to commits
    • Generally, they point to the latest commit in a line of development
  • Can create new branches with git branch <branch-name>
    • All repositories start off with one branch (normally main branch)

105 of 175

Branches

  • Branches are pointers to commits
    • Generally, they point to the latest commit in a line of development
  • Can create new branches with git branch <branch-name>
    • All repositories start off with one branch (normally main branch)
  • Can set the active branch (HEAD) with git switch <branch-name>

106 of 175

Branches

  • Branches are pointers to commits
    • Generally, they point to the latest commit in a line of development
  • Can create new branches with git branch <branch-name>
    • All repositories start off with one branch (normally main branch)
  • Can set the active branch (HEAD) with git switch <branch-name>
    • When we create a commit, we move only the active branch forward to point to the new commit

107 of 175

Branches

  • Branches are pointers to commits
    • Generally, they point to the latest commit in a line of development
  • Can create new branches with git branch <branch-name>
    • All repositories start off with one branch (normally main branch)
  • Can set the active branch (HEAD) with git switch <branch-name>
    • When we create a commit, we move only the active branch forward to point to the new commit
    • This means development on the active branch does not affect other branches

108 of 175

Branching allows you to have other lines of development

6af3e2

Initial commit

8954de

Created Cafe subclass

cafe

stars

7df53a

Added star ratings

cf3780

Created Cafe subclass

main

HEAD

109 of 175

Merging

  • Branching allows us to have lines of development that diverge from main

110 of 175

Merging

  • Branching allows us to have lines of development that diverge from main
  • Join two lines of development back together by merging them!

111 of 175

Merging

  • Branching allows us to have lines of development that diverge from main
  • Join two lines of development back together by merging them!
  • git merge <branch_name> merges the specified branch into the active branch and creates a merge commit
    • Merge commits have two parents (commits at the tips of the branches)

112 of 175

Merging joins together two lines of development

6af3e2

Initial commit

8954de

Created Cafe subclass

cafe

main

stars

7df53a

Added star ratings

cf3780

Created Cafe subclass

9478fc

Merge branch cafe

HEAD

113 of 175

Merging joins together two lines of development

  • What data structure does this look like?

6af3e2

Initial commit

8954de

Created Cafe subclass

cafe

main

stars

7df53a

Added star ratings

cf3780

Created Cafe subclass

9478fc

Merge branch cafe

HEAD

114 of 175

Merging joins together two lines of development

  • What data structure does this look like?
    • A directed acylic graph (DAG)

6af3e2

Initial commit

8954de

Created Cafe subclass

cafe

main

stars

7df53a

Added star ratings

cf3780

Created Cafe subclass

9478fc

Merge branch cafe

HEAD

115 of 175

Branching demo

Initially, our main branch starts off by pointing to our initial commit.

6af3e2

Initial commit

main

116 of 175

Branching demo

git branch cafe

6af3e2

Initial commit

main

cafe

117 of 175

Branching demo

git switch cafe

6af3e2

Initial commit

main

cafe

118 of 175

Branching demo

git commit -m “Created Cafe subclass”

6af3e2

Initial commit

8a6de7

Created Cafe subclass

cafe

main

119 of 175

Branching demo

git commit -m “Created Cafe subclass”

6af3e2

Initial commit

8a6de7

Created Cafe subclass

cafe

main

120 of 175

Branching demo

git switch main

6af3e2

Initial commit

8a6de7

Created Cafe subclass

cafe

main

121 of 175

Branching demo

git branch stars

6af3e2

Initial commit

8a6de7

Created Cafe subclass

cafe

main

stars

122 of 175

Branching demo

git switch stars

6af3e2

Initial commit

8a6de7

Created Cafe subclass

cafe

main

stars

123 of 175

Branching demo

git commit -m “Added star ratings”

6af3e2

Initial commit

8a6de7

Created Cafe subclass

cafe

main

stars

7df53a

Added star ratings

124 of 175

Branching demo

git switch cafe

6af3e2

Initial commit

8a6de7

Created Cafe subclass

cafe

main

stars

7df53a

Added star ratings

125 of 175

Branching demo

git commit -m “Added coffee ranking to Cafe.java”

6af3e2

Initial commit

8a6de7

Created Cafe subclass

cafe

main

stars

7df53a

Added star ratings

cf3780

Added coffee ranking to Cafe.java

126 of 175

Branching demo

git switch main

6af3e2

Initial commit

8a6de7

Created Cafe subclass

cafe

main

stars

7df53a

Added star ratings

cf3780

Added coffee ranking to Cafe.java

127 of 175

From linked list to trees

  • By adding the ability to create branches and other lines of development, our commit history begins to resemble a tree

6af3e2

Initial commit

8a6de7

Created Cafe subclass

7df53a

Added star ratings

cf3780

Added coffee ranking to Cafe.java

128 of 175

Branching demo

git merge main

6af3e2

Initial commit

8954de

Created Cafe subclass

cafe

main

stars

7df53a

Added star ratings

cf3780

Created Cafe subclass

9478fc

Merge branch cafe

129 of 175

Feature branches

  • Feature branch workflow means that ALL development occurs in branches apart from main

130 of 175

Feature branches

  • Feature branch workflow means that ALL development occurs in branches apart from main
  • Name feature branches according to the feature being developed
    • May also include main developer’s username (e.g.,: kanav/login-page) or category (e.g., bugfix/ratings-display)

131 of 175

Feature branches

  • Feature branch workflow means that ALL development occurs in branches apart from main
  • Name feature branches according to the feature being developed
    • May also include main developer’s username (e.g.,: kanav/login-page) or category (e.g., bugfix/ratings-display)
  • Once we finish implementing and testing on a feature branch, we can merge into the main branch.

132 of 175

Feature branches

  • Feature branch workflow means that ALL development occurs in branches apart from main
  • Name feature branches according to the feature being developed
    • May also include main developer’s username (e.g.,: kanav/login-page) or category (e.g., bugfix/ratings-display)
  • Once we finish implementing and testing on a feature branch, we can merge into the main branch.
  • Important: Test your changes on your feature branch as much as possible!

133 of 175

Feature branch demo with multiple developers

Branch: main

Commit: Release v1.1

stella

kanav

134 of 175

Feature branch demo with multiple developers

Kanav: creates find-friends branch

Branch: main

Commit: Release v1.1

Branch: find-friends Commit: Added functionality

stella

kanav

135 of 175

Feature branch demo with multiple developers

Stella: creates add-friends branch and works on it

Branch: main

Commit: Release v1.1

Branch: find-friends Commit: Added functionality

Branch: add-friends Commit: Added invite friend

Branch: add-friends Commit: Fixed add friend bug

stella

kanav

136 of 175

Feature branch demo with multiple developers

Kanav: works some more on find-friends branch

Branch: main

Commit: Release v1.1

Branch: find-friends Commit: Added functionality

Branch: find-friends Commit: Improved UI

Branch: add-friends Commit: Added invite friend

Branch: add-friends Commit: Fixed add friend bug

stella

kanav

137 of 175

Feature branch demo with multiple developers

Kanav: merges find-friends branch into main

Branch: main

Commit: Release v1.1

Branch: find-friends Commit: Added functionality

Branch: find-friends Commit: Improved UI

Branch: add-friends Commit: Added invite friend

Branch: add-friends Commit: Fixed add friend bug

stella

kanav

138 of 175

Feature branch demo with multiple developers

Step 1: Git identifies Closest Common Ancestor of find-friends and main

Branch: main

Commit: Release v1.1

Branch: find-friends Commit: Added functionality

Branch: find-friends Commit: Improved UI

Branch: add-friends Commit: Added invite friend

Branch: add-friends Commit: Fixed add friend bug

stella

kanav

139 of 175

Feature branch demo with multiple developers

Step 2: Git combines changes made between Closest Common Ancestor and the tips of branches and creates a merge commit

Branch: main

Commit: Release v1.1

Branch: find-friends Commit: Added functionality

Branch: find-friends Commit: Improved UI

Branch: add-friends Commit: Added invite friend

Branch: add-friends Commit: Fixed add friend bug

stella

Branch: main

Commit: Release v1.1

kanav

140 of 175

Feature branch demo with multiple developers

Step 2: Git combines changes made between Closest Common Ancestor and the tips of branches and creates a merge commit

Branch: main

Commit: Release v1.1

Branch: find-friends Commit: Added functionality

Branch: find-friends Commit: Improved UI

Branch: add-friends Commit: Added invite friend

Branch: add-friends Commit: Fixed add friend bug

Branch: main

Commit: Merge find-friends branch

kanav

stella

Branch: main

Commit: Release v1.1

141 of 175

Feature branch demo with multiple developers

Kanav: begins work on review branch

Branch: main

Commit: Release v1.1

Branch: find-friends Commit: Added functionality

Branch: find-friends Commit: Improved UI

Branch: add-friends Commit: Added invite friend

Branch: add-friends Commit: Fixed add friend bug

Branch: main

Commit: Merge find-friends branch

stella

Branch: review Commit: Introduced review categories

kanav

142 of 175

Feature branch demo with multiple developers

Stella: merges add-friends branch into main

Branch: main

Commit: Release v1.1

Branch: find-friends Commit: Added functionality

Branch: find-friends Commit: Improved UI

Branch: add-friends Commit: Added invite friend

Branch: add-friends Commit: Fixed add friend bug

Branch: main

Commit: Merge find-friends branch

stella

Branch: review Commit: Introduced review categories

kanav

143 of 175

Feature branch demo with multiple developers

Step 1: Git identifies Closest Common Ancestor of add-friends and main

Branch: main

Commit: Release v1.1

Branch: find-friends Commit: Added functionality

Branch: find-friends Commit: Improved UI

Branch: add-friends Commit: Added invite friend

Branch: add-friends Commit: Fixed add friend bug

Branch: main

Commit: Merge find-friends branch

stella

Branch: review Commit: Introduced review categories

kanav

144 of 175

Feature branch demo with multiple developers

Step 2: Git combines changes made since the Closest Common Ancestor and…

Branch: main

Commit: Release v1.1

Branch: find-friends Commit: Added functionality

Branch: find-friends Commit: Improved UI

Branch: add-friends Commit: Added invite friend

Branch: add-friends Commit: Fixed add friend bug

Branch: main

Commit: Merge find-friends branch

stella

Branch: review Commit: Introduced review categories

kanav

145 of 175

Feature branch demo with multiple developers

Step 2: Git combines changes made since the Closest Common Ancestor and…

Branch: main

Commit: Release v1.1

Branch: find-friends Commit: Added functionality

Branch: find-friends Commit: Improved UI

Branch: add-friends Commit: Added invite friend

Branch: add-friends Commit: Fixed add friend bug

Branch: main

Commit: Merge find-friends branch

stella

Branch: review Commit: Introduced review categories

kanav

Added findFriends() method to Friend.java

Added addFriend() method to Friend.java

146 of 175

Feature branch demo with multiple developers

Step 2: Git combines changes made since the Closest Common Ancestor and… uh oh … merge conflict

Branch: main

Commit: Release v1.1

Branch: find-friends Commit: Added functionality

Branch: find-friends Commit: Improved UI

Branch: add-friends Commit: Added invite friend

Branch: add-friends Commit: Fixed add friend bug

Branch: main

Commit: Merge find-friends branch

stella

Branch: review Commit: Introduced review categories

kanav

Added findFriends() method to Friend.java

Added addFriend() method to Friend.java

147 of 175

Collaboration on feature branches demo

Initial commit

stella

148 of 175

Collaboration on feature branches demo

Initial commit

Branch: signup Commit: Added functionality

Kanav creates signup branch

kanav

stella

149 of 175

Collaboration on feature branches demo

Initial commit

Branch: signup Commit: Added functionality

Kanav creates signup branch

Kanav pushes signup branch

kanav

stella

150 of 175

Collaboration on feature branches demo

Initial commit

Branch: signup Commit: Added functionality

Kanav creates signup branch

Kanav pushes signup branch

Stella pulls signup branch

Branch: signup Commit: Fixed bugs

stella

kanav

151 of 175

Collaboration on feature branches demo

Initial commit

Branch: signup Commit: Added functionality

Merge signup page branch into main

Branch: signup Commit: Fixed bugs

Kanav creates signup branch

Kanav pushes signup branch

Stella pulls signup branch

Stella merges sign up branch to main

Stella pushes main branch

kanav

stella

152 of 175

General advice with Git

  • Be careful with Git commands
    • Use git status and git log to check status of commits and history
    • Beware “shortcuts”
      1. git add . or git add *
      2. git push --force
  • Google is your friend. There are a lot of tips online about Git
  • If Git terminal commands fail, Git will often tell you how to fix them
    • Don’t just blindly follow, understand what they are saying
    • Again, use Google to help you

https://xkcd.com/1597/

153 of 175

Pull Requests

Lecture 31, CS61B Spring 2025

Introduction

Agile Development

Review: Git Commands

Git Branching and Merging

Pull Requests

Summary

154 of 175

Main branch

  • The main branch is often reserved for deployment
    • Deployment is the process of making software available for use by users
    • CI/CD pipelines use the main branch to test and deploy

155 of 175

Main branch

  • The main branch is often reserved for deployment
    • Deployment is the process of making software available for use by users
    • CI/CD pipelines use the main branch to test and deploy
  • What does this mean?
    • We don’t want development to occur on the main branch
    • Need safeguards to ensure that we only merge complete, functional, and well-tested changes to main
    • Paranoia!

156 of 175

Pull requests

  • How do we ensure that we only merge complete, functional, and well-tested changes?
  • Pull request (PR): way to request that your changes be merged into main
    • Developers can review your changes, leave feedback, and approve the request
    • Good practice for others to review your code before it’s merged!
    • Most major tech companies mandate that at least one additional person review your code

157 of 175

Pull requests

  • How do we ensure that we only merge complete, functional, and well-tested changes?
  • Pull request (PR): way to request that your changes be merged into main
    • Developers can review your changes, leave feedback, and approve the request
    • Good practice for others to review your code before it’s merged!
    • Most major tech companies mandate that at least one additional person review your code
  • You can contribute to open-source projects (e.g. Firefox) by making a pull request
    • A maintainer will review your changes and provide feedback

158 of 175

Pull requests example

Branch: signup Commit: Basic UI

Kanav pulls signup branch

kanav

159 of 175

Pull requests example

Branch: signup Commit: Basic UI

Kanav pulls signup branch

Kanav opens PR signup branch

kanav

160 of 175

Pull requests example

Branch: signup Commit: Basic UI

Kanav pulls signup branch

Kanav opens PR signup branch

Stella leaves feedback on PR

kanav

161 of 175

Pull requests example

Branch: signup Commit: Basic UI

Kanav pulls signup branch

Kanav fixes Stella’s feedback

Branch: signup Commit: Improved UI

Kanav opens PR signup branch

Stella leaves feedback on PR

Kanav pushes changes to signup branch

kanav

162 of 175

Pull requests example

Merge signup page branch into main

Branch: signup Commit: Basic UI

Kanav pulls signup branch

Kanav fixes Stella’s feedback

Branch: signup Commit: Improved UI

Kanav opens PR signup branch

Stella leaves feedback on PR

Stella approves PR and merges into main

Kanav pushes changes to signup branch

kanav

163 of 175

Writing good PRs

  • The goal of a PRs is to get feedback on your code
    • Be explicit about what feedback you want
    • @mention individuals involved
    • Keep PR descriptions and commit messages professional and informative
  • Important: keep the code changes in a PR small
    • Easier to review a small code change than a big one!
    • Average PR size is 50-200 lines of code (GitHub)
  • Storytime

GitHub PR template in Markdown

164 of 175

Code reviews

Key part of pull requests: someone can leave feedback on your code! This is called a code review.

  • Reviewers can comment on specific lines of code
  • Can cover both high-level concerns and low-level issues
  • Reviewers provide actionable suggestions for improvement
  • Back-and-forth discussion between author and reviewers
  • Author can push updates to address feedback, PR automatically refreshes

165 of 175

Why Code Review?

166 of 175

GitHub Pull Request Demo

PR description

Reviewer assigned

167 of 175

GitHub Pull Request Demo

Reviewer comments

168 of 175

GitHub Pull Request Demo

Updated PR lines shown in green, removed in red, auto refresh update once pushed!

169 of 175

GitHub Pull Request Demo

Final reviewer comment

PR ready for merge with main

170 of 175

Summary

Lecture 31, CS61B Spring 2025

Introduction

Agile Development

Review: Git Commands

Git Branching and Merging

Pull Requests

Summary

171 of 175

Summary (Git + Jira + Customer)

  1. First, we talked about using Jira for organizing Agile/Scrum development

Assigned ticket in Jira

Communicate with product manager to understand task better

Customer feedback

172 of 175

Summary (Git + Jira + Customer)

2. Second, we talked about git workflows like feature branches to develop these items

Assigned ticket in Jira

Create a feature branch to code and test your changes

Communicate with product manager to understand task better

Merge to main, ready for deployment!

Customer feedback

Use Git version history to understand past work

173 of 175

Summary (Git + Jira + Customer)

3. Third, we discussed how the PR and code review process was key for code quality and releasing to main

Assigned ticket in Jira

Create a feature branch to code and test your changes

Open a new pull request or update an existing one

Communicate with other engineers through a code review

Communicate with product manager to understand task better

Merge to main, ready for deployment!

Customer feedback

Use Git version history to understand past work

174 of 175

Collaboration

Customers

Engineers

Past and future employees

Product managers, designers

You

175 of 175

Summary (Collaboration is key)

Lessons: Collaboration is key. Opportunities to collaborate with customers, product managers, other engineers, and past/future employees exist throughout the process!

Assigned ticket in Jira

Create a feature branch to code and test your changes

Open a new pull request or update an existing one

Communicate with other engineers through a code review

Communicate with product manager to understand task better

Merge to main, ready for deployment!

Customer feedback

Use Git version history to understand past work