use git rebase -i master
then editor will open change status of each commit with the following commands
# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
# f, fixup = like "squash", but discard this commit's log message
# x, exec = run command (the rest of the line) using shell
# d, drop = remove commit
For example
You rebase the master then run the command git rebase -i master
after the you will see some commits (suppose) like this
pick cf2cf55 C-1: Added new commit
pick c7d2f77 C-3: Allow user
pick 7db9f8d C-5: added new commit
pick 2a2e8cf C-6: Removed quick edits
The format for the above content is <command> <commit-id> <commit message>
.
Now you need to squash all commit into single commit then change pick command with your required command.
suppose we need to merge all commit into single commit then we use command s
or squash
like this
pick cf2cf55 C-1: Added new commit
s c7d2f77 C-3: Allow user
s 7db9f8d C-5: added new commit
s 2a2e8cf C-6: Removed quick edits
after save this. This will squash all other commits beside C-1
. Now if you want to change commit messgae change it then save.
That's All.