You can modify the most recent commit in the same branch by running git commit --amend. This command is convenient for adding new or updated files to the previous commit. It is also a simple way to edit or add comments to the previous commit.
Rebasing is the process of taking all the changes that were committed on one branch and applying them to a new branch.
Run git rebase and add in the -i option to rewrite, replace, delete, and merge individual commits in the history. You can also:
Rewrite a past commit message
Squash a group of commits together
Add files that have not been committed
You can apply an existing commit from another branch to the current branch within the repository by using the git cherry-pick command. Cherry-picking allows you to:
Move a commit that was committed to the wrong branch to the right branch.
Add a commit to the current branch based on an existing commit from another branch.
Squashing is the process of merging multiple commits into a single commit.
If you run git merge and the --squash option, a new commit will group all of the commits from that branch together. The commit will be used to merge into the current branch.