So you made some mistake with your previous commit but dont want to make hundreds of commits and want to have nice looking reflog. You can do some rebasing with this command
git rebase -i HEAD~{number of commits you need to work with}
you will get interactive mode where you will get the list of commits opened in your default text editor, if you want to merge a commit to the upper one, just change "pick" to "squash" and after you do that you save and exit. After that automatically you will get opened text file to edit/combine your commit messages and after you do that, you save and exit again and you are done locally.
You then need to push that to remote, so you will need to do
git push -f
which is a FORCE flag. The --force
flag overrides normal behavior and makes the remote repository’s branch match your local one, deleting any upstream changes that may have occurred since you last pulled, so use this only if you are the only one working on this branch, otherwise you can remove changes from some other developers.