Lecture 3 Branches, Summaries of History

Commits are made on whatever branch you're on. B. A. 1. git commit –m “A”. 2. git commit –m “B”. 3. git branch experiment master.

Typology: Summaries

2022/2023

Uploaded on 02/28/2023

anandit
anandit 🇺🇸

4.8

(19)

255 documents

1 / 41

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Lecture 3
Branches
Sign in on the
attendance
sheet!
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29

Partial preview of the text

Download Lecture 3 Branches and more Summaries History in PDF only on Docsity!

Lecture 3

Branches

Sign in on the attendance sheet!

Last Time

Scenario: You work on two features at once in a project b4e2c29: initial commit b5f3729: even more work on feature A 8277e09: even more work on feature B 8b7d883: begin work on feature B 8fc42c6: begin work on feature A 6f96cf3: more work on feature A e167179: more work on feature B master, HEAD

Scenario: You work on two features at once in a project b4e2c29: initial commit b5f3729: even more work on feature A 8277e09: even more work on feature B 8b7d883: begin work on feature B 8fc42c6: begin work on feature A 6f96cf3: more work on feature A e167179: more work on feature B master, HEAD

  • Hard to distinguish the two different features that are being worked on based on the git history
  • If the features are related, the commits might interfere with each other

Activity!

git branch Example use: git branch

  • Lists all the local branches in the current repository and marks which branch you’re currently on - Where are “you”? Well, you’re always at HEAD. Usually, you’re also at a branch as well.
  • The default branch in a repository is called “master”

git checkout Example use: git checkout develop

  • Switches to the branch named “develop”
  • Instead of a branch name, you can also put a commit hash
    • More on this next lecture

Commits are made on whatever branch you’re on A

  1. git commit – m “A”
  2. git commit – m “B” master HEAD

Commits are made on whatever branch you’re on B A

  1. git commit – m “A”
  2. git commit – m “B”
  3. git branch experiment
  4. git checkout experiment master HEAD experiment

Commits are made on whatever branch you’re on B A

  1. git commit – m “A”
  2. git commit – m “B”
  3. git branch experiment
  4. git checkout experiment
  5. git commit – m “C” master experiment HEAD

Commits are made on whatever branch you’re on B A C D

  1. git commit – m “A”
  2. git commit – m “B”
  3. git branch experiment
  4. git checkout experiment
  5. git commit – m “C”
  6. git commit – m “D”
  7. git branch wildidea master experiment HEAD

Commits are made on whatever branch you’re on B A C D

  1. git commit – m “A”
  2. git commit – m “B”
  3. git branch experiment
  4. git checkout experiment
  5. git commit – m “C”
  6. git commit – m “D”
  7. git branch wildidea
  8. git checkout wildidea master experiment HEAD wildidea

Commits are made on whatever branch you’re on B A C D E

  1. git commit – m “A”
  2. git commit – m “B”
  3. git branch experiment
  4. git checkout experiment
  5. git commit – m “C”
  6. git commit – m “D”
  7. git branch wildidea
  8. git checkout wildidea
  9. git commit – m “E”
  10. git checkout master master HEAD experiment wildidea

Commits are made on whatever branch you’re on B A C D E

  1. git commit – m “A”
  2. git commit – m “B”
  3. git branch experiment
  4. git checkout experiment
  5. git commit – m “C”
  6. git commit – m “D”
  7. git branch wildidea
  8. git checkout wildidea
  9. git commit – m “E”
  10. git checkout master
  11. git commit – m “F” master HEAD experiment wildidea