Squash Git commit

I use Git every day and writeGit guidewith oneGit cheat sheetIn the past.

I consider myself a fan of Git, but...I am not an expert in Git.

Submit, get the origin, pull the origin, press into the origin... This is the time I use Git every day.

and IsomeGit:

I was shocked by the advanced things Git can do. It can be very complicated, and I tend to avoid all this complexity. I almost never use Git on the command line, I useGitHub desktopThis is the simplest and best Git client ever.

The two things I sometimes do arePicking cherrieswithSqueeze submission.

Let's talk about it.

In projects where I am the only developer, this means that for all my personal projects, I will tend to use master when possible. For example, if I want to make simple changes, or add new posts to the blog. Something fast and uninterrupted.

However, in some cases, I don't use this method and instead create a branch for large functions.

This is also the default setting when working on a team or open source project.

You create a branch and commit frequently. Committing early and often is a great advantage, because you can write code with confidence that you can always return to a working state, or at least to a state where you know something works.

You might perform a series of quick commits where the message is "OK", "Try this action" or "Fix stupid error".

But at some point, you need to converge to a stable state and commit the changes back to master or whatever branch you want.

Before that, you want to do one thing: compress the submission.

GitHubThis can be done automatically for you when merging "merge requests," and this is a workflow that I have used frequently in public open source repositories in the past.

You only see one submission, instead of seeing all the individual submissions included in the "pull request", and during the PR merge process, you can write detailed and dedicated submission messages and descriptions.

This will eliminate all previous Git commits that were different from the merged branch's branch, and delete all commits where you might have reverted changes, and so on.

This is squeezing the GitHub PR process. You can also compress commits outside of GitHub.

After you finish your work on the branch, merge the master (or any other branch you want to merge) into it:

git merge master

So you can deal with any update conflicts there.

Then you check out the master and run from there:

git merge --squash <your-feature-branch>


git commit

This is just one of the possible workflows you can use, and it's very easy to do all the work with GitHub, and this option can minimize your headaches.

More git tutorials: