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"
Then this commit message will not exist. However, the information for this commit has been merged into "my message here".
The second is that if you submit a final modification, this is available:
$ git reset--soft head^ #或HEAD ^ meaning to cancel the final commit
$ git commit--amend
This will merge the last commit into the previous commit, for example (read up and down):
git add B.text
Git commit-a-M "My message Here"
git add A.text
Git 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!
"Go" git merge commit