Home git How does git merge --squash work?

How does git merge –squash work?




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 :


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 .

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions