Check out example codes for "squash commits in git". It will help you in understanding the concepts better.

Code Example 1

git reset --soft HEAD~3 &&
git commit

Learn ReactJs, React Native from akashmittal.com