I have a remote Git server, here is the scenario which I want to perform:
-
For each bug/feature I create a different Git branch
-
I keep on committing my code in that Git branch with un-official Git messages
-
In top repository we have to do one commit for one bug with official Git message
So how can I merge my branch to remote branch so that they get just one commit for all my check-ins (I even want to provide commit message for this)?
Best Answer
Say your bug fix branch is called
bugfix
and you want to merge it intomaster
:This will take all the commits from the
bugfix
branch, squash them into 1 commit, and merge it with yourmaster
branch.Explanation:
Switches to your
master
branch.Takes all commits from the
bugfix
branch and groups it for a 1 commit with your current branch.(no merge commit appears; you could resolve conflicts manually before following commit)
Creates a single commit from the merged changes.
Omitting the
-m
parameter lets you modify a draft commit message containing every message from your squashed commits before finalizing your commit.