- Run
source setup.sh
(or.\setup.ps1
in 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 --all
to view all the branches and their commits. - Copy
C
ontomaster
beforeB
by rebasingquickfix
onmaster
. - Make a new branch (
changes-including-B
) off of ourmaster
so we can keep working onB
. - Reset
master
back toC
. - Delete the
quickfix
branch. - Push
master
. You can't do this in the training exercise. - You can merge the
changes-including-B
branch tomaster
and deletechanges-including-B
or just switch tochanges-including-B
and work there.
git log --oneline --graph --all
git switch <branch-name>
git rebase <branch-name>
git branch <branch-name>
git reset --soft HEAD~
git branch -d <branch-name>
git merge <branch-name>