I noticed that sometimes instead of git pull --rebase
I do this
git checkout remote_my / branch_my
git merge --squash branch_my
git commit ...
What is the meaning of this code
Answer 1, authority 100%
From Git Reference – merge :
–squash
Treats the work area and index as if it were a merge, but does not actually commit, move the
HEAD
pointer, or write anything to$ GIT_DIR / MERGE_HEAD
. This allows you to make a single commit to the current branch, containing all the same changes that would have been applied in a normal branch merge (or multiple, in the case of a complex merge).
How it works
git checkout master
git merge --squash feature123
git commit -m'merged feature # 123 '
All changes in feature123 become one commit in master.
This is useful if the branch contains a lot of minor commits that are “uninteresting” for general history. After such an operation, the branch history will remain “flat”, just like after git pull --rebase
.