If you have pushed a commit and then realized that you need to make a small change that should be included in the commit's context. You can use the git commit --amend --no-edit command to modify the most recent commit with the same message or git commit --amend -m to override the message as well.
You might need to use git push -f to force push the overrides.
This will allow you to add the small change and update the commit message if necessary. This strategy can be applied, for instance, if you forgot to apply linting or add a comment or update the commit message and so forth.
However, if you have already pushed the commit to a branch that maintained by multiple developers, you should avoid amending the commit as it can cause problems for other users who have already based work on the original commit. In this case, it's better to create a new commit that includes the small change and push that to the remote repository.
OnePublish: https://www.onepubli.sh | Cross-publish your tech content from Notion to DEV, Hashnode, Medium, Ghost and more.
Developer Timeline - https://www.developertimeline.io | Sharing real experience