This is simple repository to practice some of the concepts taught in Common Code's Git Master Class training course.
Here we cover an example of interactive rebasing and using a merge strategy for rebasing.
The only file (apart from this one) is manuscript.md which is a plain text passage of English.
There is a series of branches already created to set the scene for this activity.
Try to perform the tasks using commands in your computer terminal - if you get stuck then click 'Show me how'
First off, clone and/or fork this repository locally.
Show me how
mkdir commoncode
cd commoncode
git clone [email protected]:commoncode/git-masterclass-activity-1.git
cd git-masterclass-activity-1
To restart the exercise at any time just rm -Rf git-masterclass-activity-1
and re-clone.
This repo has a couple of branches with a sequence of commits resulting in a tree like this:
E --- F --- K --- L feature_2
/
C --- D --- I --- J feature_1
/
A --- B --- G --- H master
Inspect the git log for all branches and verify the above structure
Show me how
# The --all flag specifies all branches
git log --graph --oneline --all
Interactively rebase
feature_1
branch ontomaster
and squash commits I + J.
The goal is to have a new master branch with commits as
A --- B --- C --- D --- I+J' --- H'...
Where H'
is the same change as H
and I+J'
is the combined changes of I
and J
.
Note that commits G and C conflict - they both change the same line.
Show me how
# Rebase feature_1 onto master
git checkout master
git rebase origin/feature_1
## Commits G' and C conflict - however we want C as our latest change. Open up your editor and select C changes
git add .
git rebase --skip
## Commit H conflicts with feature_1 current state. Select H' change over feature_1.
git add .
git rebase --contiue
# Squash J into I
git rebase -i HEAD~6
# in the rebase file, change line two to: squash 0d45141 J - incredible
# in the commmit message file make the commit text: "I+J - understanding and incredible" and comment out "J - incredible"