git rebase --Modify and combine multiple commits
The git rebase command is a command that modifies and combines multiple commits. Newly created commits can be merged fast forward ahead of the branch from which they were derived.
git rebase Derived from branch
Suppose you create a foo branch that branches off from the main branch and proceed with commits "A", "B", and "C". If you specify the main branch of the derivation source with "git rebase", one commit that combines multiple "A", "B", and "C" will be created. This can be merged fast forward when merged into the main branch.
Since git rebase is a command that modifies and puts together commits, it is a command that can corrupt the repository. With git branch, it's a good idea to create a working branch for git rebase.
git branch foo_rebase git checkout foo_rebase
Don't "git rebase" for "git push"
The caveat of "git rebase" is that you don't "git rebase" anything you "git push". "Git rebase" only for branches that haven't been pushed.
When do you want to use "git rebase"?
The first is to derive a branch, stack small changes, commit more and more, save, and develop. Commits also have the purpose of saving, so there is a desire to keep them small.
However, in this case, the merge is very fine-grained and is not a functional unit comment. From the point of view of the merged side, the history will be uncluttered.
In such a case, "git rebase" will clean the history.
As an example, in my case, I generally use git merge merges when developing web applications for end users. Keeping your history clean is a rare case. Also, in open source development, if you want your changes to be merged, use "git rebase" to clean them up.