Docsity

Lecture 3 Branches, Summaries of History

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