Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
+4 votes
2 views
in DevOps and Agile by (19.4k 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

+4 votes
by (27.5k 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:

 

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...