sometimes a commit is too much, and maybe a commit just commits a small bug, so merging commits is imperative.
There are two ways of doing this:
one is to commit the last modified commit using parameters, and a previous commit will be merged into this commit commit:
git commit-a--amend-m "My message here" if there was a commit before, and the information is:
Git commit-a-M "My last Commit message"
This commit message will not exist. However, the information for this commit has been merged into "my message here".
$ git reset--soft head^ #或HEAD ^ means to cancel the last commit
$ git commit--amend
This will merge the last commit into the previous commit, for example (read up and down):
git add b.textgit commit-a-M "My message here" git add a.textgit commit-a-M "My last Commit message"
Then there will be "my last commit message". You can also back N, merging into the previous n+1 commit:
$ git reset--soft head~n #后退到第n, and I don't know exactly what it means.
$ git commit--amend [-M "New message"]
I think the most aspect is to call Reflog to view the operation history, find the specific commit ID, and then direct git reset--hard [commit_id] back to the version you want!
Git commit Merge