- Run
source setup.sh(or.\setup.ps1in PowerShell)
This kata was shameless ripped off from Git Katas
You are working really hard on the master branch. Part of your work is already committed. This is when your boss comes in with an urgent request.
Since your current HEAD is not ready for prime time you backup one commit, and start a new branch named 'quickfix'. You do whatever your boss wants and commit the changes to that new branch.
That's when you realize you created a minor mess with your branches.
Currently your commits look like this
master
|
v
A <---- B
^ \
| \--- C
remote ^
|
quickfix
But you want it to look like this:
remote
|
v
A <---- C <---- B
^
|
HEAD
Git ahead!
Note: since the B in the current and in the target structure don't have the same parent they can't be literally the same commit.
- Use
git log --oneline --graph --allto view all the branches and their commits. - Copy
ContomasterbeforeBby rebasingquickfixonmaster. - Make a new branch (
changes-including-B) off of ourmasterso we can keep working onB. - Reset
masterback toC. - Delete the
quickfixbranch. - Push
master. You can't do this in the training exercise. - You can merge the
changes-including-Bbranch tomasterand deletechanges-including-Bor just switch tochanges-including-Band work there.
git log --oneline --graph --allgit switch <branch-name>git rebase <branch-name>git branch <branch-name>git reset --soft HEAD~git branch -d <branch-name>git merge <branch-name>