Setup#
Type this in to begin the process of working through a real example of squashing and understand what it is:
1 mkdir lgthw_squashing
2 cd lgthw_squashing
3 git init
4 touch afile
5 git add afile
6 git commit -m "Initial commit"
7 for i in {1..10}
8 > do
9 > echo $i >> afile
10 > git commit -am "commit:${i}"
11 > done
12 git status
13 git log
You have created a Git repository with a history and seen its Git log.
Cloning#
Clone it into a new folder:
14 cd ..
15 git clone lgthw_squashing lgthw_squashing_clone
17 cd lgthw_squashing_clone
18 git remote -v
19 git log
You can see the remote of this second repository is set to the original one you created above, and the history has ten commits.
We’ve decided that this history is too complicated for us. We want to squash these ten commits into a single one that has the number 10
in afile
.
Introduction: Squashing Commits
The 'git rebase -i' Command
Mark as Completed
Report an Issue