Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git push all commits as single commit with custom message

I was wondering if it is possible to push all my local commits (all 'unpushed' commits of the day) to the remote repository as a single commit with a custom message. None of the posts on Stack Overflow seem to answer this. I'm using Git Bash on Windows.

Thanks in advance.

like image 623
Lukas Avatar asked Apr 18 '12 10:04

Lukas


2 Answers

Use git rebase -i HEAD~N where N is <the number of your commits> + 1 (to be on the safe side). You will need to mark all your commits but the first one as s (stands for "squash") and save/quit the editor. It will ask you for the commit message for the final squashed commit - specify one, and you are done.

like image 171
Alexander Pavlov Avatar answered Oct 24 '22 06:10

Alexander Pavlov


What you want to do is called "squash". Take a look here:

https://makandracards.com/makandra/527-squash-several-git-commits-into-a-single-commit

like image 27
Juan G. Hurtado Avatar answered Oct 24 '22 07:10

Juan G. Hurtado