Combining multiple commits before pushing in Git

Combining multiple commits before pushing in Git

Asked on January 8, 2019 in Git.
Add Comment


  • 3 Answer(s)

    “Squashing” in git to merge all of your unpushed commits:

    git rebase -i origin/master
    

    -i interactive the file in text editor:

    pick 16b5fcc Code in, tests not passing
    pick c964dea Getting closer
    pick 06cf8ee Something changed
    pick 396b4a3 Tests pass
    pick 9be7fdb Better comments
    pick 7dba9cb All done
    

    Alteration the pick to squash :

    pick 16b5fcc Code in, tests not passing
    squash c964dea Getting closer
    squash 06cf8ee Something changed
    squash 396b4a3 Tests pass
    squash 9be7fdb Better comments
    squash 7dba9cb All done
    

    Save your file and exit your editor file and then another text editor will open to combine the message from  this file.

    Answered on January 8, 2019.
    Add Comment

    Here the  following below code for commit ID :

    git rebase -i <that_commit_id>
    
    

    Changing all the picks to squashes other than the first one.

    Answered on January 8, 2019.
    Add Comment

    Just replace pick with squash in order to remove/merge

    git rebase -i HEAD~4
    
    

    4 is the number of commits to squash.

    Answered on January 8, 2019.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.