If you need to overwrite all commits on a branch , try the following steps : Check out the branch for which you want to overwrite all commits in one commit. Let’s say its called, feature_branch.
git checkout feature_branch
Perform a soft reset of your origin / feature_branch with your local branch masters (depending on your needs, you can also reset with origin / master). This will reset any additional commits in your feature_branch, but without locally modifying your file changes.
git reset --soft master
Add all the changes in your git repo directory, to the new commit that will be created. And engage the same with a message.
git add -A && git commit -m "commit message goes here"