Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are there any Git command to combine all our ugly commits together to one?

Tags:

git

When I write the code in local, sometimes I commit the code that isn't clean yet, or, with an ugly message as temporary revision.

However, when I want my code to merge with the others, I would like the only final snapshot that the other can see, (hidden the revisions that look ugly)

Ex. I fork 0 to my local repository, I make change and test and commit with unclean code

0->1->2->3->4->5->6 (Final code)

when the others pull the code, is it possible to make other see only final state? and not see the tree from 1..5

I want users will see like

0------------------->6

One way I can think of is making a patch file, but it not good enough if there is some file have to be deleted or create.

like image 491
scalopus Avatar asked Feb 03 '23 14:02

scalopus


1 Answers

You can use reset --soft to squash multiple commits into a single new clean commit. With your branch at the final code with no staged changes you can do:

git reset --soft <sha1-of-0>
git commit

When git commit prompts, give a clear commit message describing the complete changes being introduced.

like image 99
CB Bailey Avatar answered Feb 05 '23 02:02

CB Bailey