Squash Commits via the git rebase Command
Learn to squash multiple commits using git rebase.
We'll cover the following...
Add files and commits
In the terminal provided at the end of the lesson, we add some files and make changes to them. We create two files, file1.txt
and file2.txt
. Two branches, main
and feature_a
, are also created. We add four lines to file2.txt
, one after the other. We have already run these commands in the terminal at the end of the lesson.
$ git checkout -b main
$ touch file1.txt
$ git add file1.txt
$ git commit -m "creation of file1"
$ git checkout -b feature_a
$ touch file2.txt
$ git add file2.txt
$ git commit -m "creation of file2"
$ echo "line 1" >> file2.txt
$ git add file2.txt
$ git commit -m "line 1 file 2"
$ echo "line 2" >> file2.txt
$ git add file2.txt
$ git commit
...