benthayer / git-gud

Wanna git gud? Then get git-gud, and git gud at git!
MIT License
401 stars 42 forks source link

Level: Rewriting History 5 - "Splitting Hairs" #259

Open benthayer opened 3 years ago

benthayer commented 3 years ago
5) Splitting Hairs - Split the changes from the first branch to be on two branches

Work1, Work2, Work3 all go together Start Fixing Bug is part of a separate set of changes They each belong on their own branch

The level is complete when the changes from Work1, Work2, Work3 are on their own branch and the changes from Start Fixing Bug are on their own branch too. The branches can be named whatever. "master" should stay the same

git gud status

master:
Commits: Initial Commit
Files: file.txt

branch1:
Commits: Work1, Work2, Work3
Files: file1.txt, file2.txt, file3.txt

Other branch:
Commits: Start Fixing Bug

Work2 has one change that depends on "Start Fixing Bug" that results in a conflict

Start:
Initial (master) ---- Work1 ---- Start Fixing Bug ---- Work2 ---- Work3 (branch1)

End:
Initial (master) ---- Work1 ---- Work2 ---- Work3 (branch1)
     \
  Start Fixing Bug (bugFix)

Contents can be somthing like this:
Initial:
Hello mom
Hello dad

Work1:
Hello earth

Start Fixing Bug: (Changes text to say goodbye rather than hello)
Goodbye earth

Work2:
Goodbye world