GIT Squash : How to convert multiple commits into single commit ?

First of all set notepad ++ as default editor to open git messages 

To set notepad ++ as default editor in squash

git config –global core.editor “‘C:/Program Files/Notepad++/notepad++.exe’ -multiInst -notabbar -nosession -noPlugin”

To apply squash follow the steps  

1) To check number of  commits in given branch 
   git log –oneline -10 


2) To combine two or more commits in single commit 
   git rebase –interactive head~3  // 3 is the number of logs or commits you need to merge in single commit 

3) opens file in file editor
    you will see 
    pick
    pick
    pick

   change to (Here change all pick to squash except first pick)
   pick – pick  
   pick – squash
   pick – squash
   save the file and close

4) again file is opened 
    comments will be shown using # 
     use first commit message for adding/updating new comment for single commit.
     remove commit messages other than first commit 
     save the file and close 

By:

Posted in:


Leave a comment