My answers to all the problems in the learngitbranching.js.org
Note
I've used git checkout
but you can use git switch
instead of checkout.
git commit
git commit
git checkout -b bugFix
git checkout -b bugFix
git commit
git checkout main
git commit
git merge bugFix
git checkout -b bugFix
git commit
git checkout main
git commit
git checkout bugFix
git rebase main
git checkout c4
git checkout HEAD^
git checkout HEAD^
git branch -f main c6
git branch -f bugFix c0
git reset local^
git checkout pushed
git revert pushed
git cherry-pick c3 c4 c7
git rebase -i HEAD~4
3 different answers that I find to solve the problem
git branch -f bugFix c1
git cherry-pick c4
git branch -f main c4'
OR
git rebase -i main
git branch -f main c4'
OR - BEST Solution
git rebase -i HEAD~3
git branch -f main c4'
git rebase -i HEAD~2
git commit --amend
git rebase -i HEAD~2
git branch -f main c3''
OR
git rebase -i HEAD~2
git rebase -i HEAD~1
git rebase -i HEAD~2
git branch -f main c3''
git checkout main
git cherry-pick c2
git rebase -i HEAD~1
git cherry-pick c3
OR - BEST Solution
git checkout main
git cherry-pick c2
git branch -f main c1
git cherry-pick c2' c3
git tag v0 c1
git tag v1 c2
git checkout c2 (OR) git checkout main^
git describe main #output: v0_2_gC2
git describe side #output: v1_1_gC4
git describe bugFix #output: v1_2_gC6
git checkout bugFix
git rebase c2
git checkout main
git branch -f main c4
git rebase c3'
git branch -f main c5
git rebase c4'
git branch -f main c6
git rebase c5'
git branch -f main c7
git rebase c6'
git branch -f another c7'
git branch -f side c6'
OR
git rebase main bugFix
git rebase bugFix side
git rebase side another
git branch -f main c7'
OR - BEST Soltion
git rebase main bugFix
git rebase bugFix side
git rebase side another
git rebase another main
git branch -f bugWork c2
OR - BEST Soltion
git branch bugWork main~^2~
git rebase -i one main
git branch -f main c5
git rebase -i one main
git branch -f main c5
git branch -f one c2'
git branch -f two c2''
git branch -f three c2
git checkout two
OR - BEST Solution
git checkout one
git cherry-pick c4 c3 c2
git checkout two
git cherry-pick c5 c4 c3 c2
git branch -f three c2
git clone
git commit
git checkout o/main
git commit
git fetch
git fetch
git merge o/main
OR - BEST solution
git pull
git clone
git fakeTeamwork main 2
git commit
git pull
OR
git clone
git commit
git fakeTeamwork main 2
git pull
git commit
git commit
git push
git clone
git fakeTeamwork main
git commit
git fetch
git rebase o/main
git push
OR - BEST Solution
git clone
git fakeTeamwork main
git commit
git pull --rebase
git push
git checkout -b feature
git branch -f main c1
git push
OR - BEST Solution
git reset o/main
git checkout -b feature c2
git push # Can also use- git push origin feature
git branch -f side3 c1
git pull origin main
git cherry-pick c2 c3 c4 c5 c6 c7
git branch -f side1 c2'
git branch -f side 2 c4'
git branch -f main c7'
git push origin main
OR - BEST Solution
git fetch #Can also use- git fetch origin main
git rebase o/main side1
git rebase side1 side2
git rebase side2 side3
git rebase side3 main
git push #Can also use- git push origin main
git checkout main
git pull origin main
git merge side1
git merge side2
git merge side3
git push origin main
git checkout -b side o/main
git commit
git pull --rebase
git push
git push origin main
git push origin foo
git push origin main^:foo
git push origin foo:main
git fetch origin c3:foo
git fetch origin c6:main
git checkout foo
git merge main
git push origin :foo
git fetch origin :bar
git fetch origin c3:foo
git fetch origin c2:side
git merge foo
git merge side
OR - BEST Solution
git pull origin c3:foo
git pull origin c2:side
🧑💻 Huh, finally completed all levels.
Note
If found any mistake or better answers, send PR, I'll merge it.