+5 votes
1 view
in Devops and Agile by (20k points)
edited by

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 the 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)?

1 Answer

+5 votes
by (28.4k points)
edited by

Case 1: First, switch to your master branch

$ git checkout master

Step 2: Then,  to take all the commits from the bugfix branch and merges it with the current branch

$ git merge --squash bugfix

Step 3: Now, to create a single commit from the merged changes

$ git commit

For better understanding of git life-cycle please refer:

Welcome to Intellipaat Community. Get your technical queries answered by top developers !