When you use the git in your project, you could face a problem about how to combine your loose commits into one commit.
For Examples, I have the commit log like this.
1 | First commit |
I want to conbine commits of the fix1, fix2 and adjust wording into second commit.
It looks great and clear.
1 | First commit |
In order to become this result, we can use the git command, rebase.
1 | git rebase -i <SHA> |
- SHA : It means the base commit. In this case, the SHA is First commit.
Then you can use the two commands and adjust your commits.
- pick : use commit
- squash : use commit, but meld into previous commit
The git-operation gif
![](/2022/09/01/Combine-multiple-commits-into-one-commit-in-git/rebase.gif)
The steps following:
1 | 1. Use the command "git rebase -i <SHA>" |