DEV Community

Nguyen Hoang
Nguyen Hoang

Posted on

๐ญ๐ก๐ž ๐๐ข๐Ÿ๐Ÿ๐ž๐ซ๐ž๐ง๐œ๐ž๐ฌ between ๐†๐ข๐ญ ๐Œ๐ž๐ซ๐ ๐ž and ๐†๐ข๐ญ ๐‘๐ž๐›๐š๐ฌ๐ž.

Image description

Let me tell you ๐ญ๐ก๐ž ๐๐ข๐Ÿ๐Ÿ๐ž๐ซ๐ž๐ง๐œ๐ž๐ฌ between ๐†๐ข๐ญ ๐Œ๐ž๐ซ๐ ๐ž and ๐†๐ข๐ญ ๐‘๐ž๐›๐š๐ฌ๐ž.
๐˜ž๐˜ฉ๐˜ฆ๐˜ฏ ๐˜ธ๐˜ฆ ๐ฆ๐ž๐ซ๐ ๐ž ๐œ๐ก๐š๐ง๐ ๐ž๐ฌ ๐˜ง๐˜ณ๐˜ฐ๐˜ฎ ๐˜ฐ๐˜ฏ๐˜ฆ ๐˜Ž๐˜ช๐˜ต ๐˜ฃ๐˜ณ๐˜ข๐˜ฏ๐˜ค๐˜ฉ ๐˜ต๐˜ฐ ๐˜ข๐˜ฏ๐˜ฐ๐˜ต๐˜ฉ๐˜ฆ๐˜ณ, ๐˜ธ๐˜ฆ ๐˜ค๐˜ข๐˜ฏ ๐˜ถ๐˜ด๐˜ฆ โ€˜๐˜จ๐˜ช๐˜ต ๐˜ฎ๐˜ฆ๐˜ณ๐˜จ๐˜ฆโ€™ ๐˜ฐ๐˜ณ โ€˜๐˜จ๐˜ช๐˜ต ๐˜ณ๐˜ฆ๐˜ฃ๐˜ข๐˜ด๐˜ฆโ€™.

๐˜›๐˜ฉ๐˜ฆ ๐˜ฅ๐˜ช๐˜ข๐˜จ๐˜ณ๐˜ข๐˜ฎ ๐˜ฃ๐˜ฆ๐˜ญ๐˜ฐ๐˜ธ ๐˜ด๐˜ฉ๐˜ฐ๐˜ธ๐˜ด ๐˜ฉ๐˜ฐ๐˜ธ ๐˜ต๐˜ฉ๐˜ฆ ๐˜ต๐˜ธ๐˜ฐ ๐˜ค๐˜ฐ๐˜ฎ๐˜ฎ๐˜ข๐˜ฏ๐˜ฅ๐˜ด ๐˜ธ๐˜ฐ๐˜ณ๐˜ฌ.

๐†๐ข๐ญ ๐Œ๐ž๐ซ๐ ๐ž
This creates a new commit Gโ€™ in the main branch. Gโ€™ ties the histories of both main and feature branches.

Git merge is ๐ง๐จ๐ง-๐๐ž๐ฌ๐ญ๐ซ๐ฎ๐œ๐ญ๐ข๐ฏ๐ž. Neither the main nor the feature branch is changed.

๐†๐ข๐ญ ๐‘๐ž๐›๐š๐ฌ๐ž
Git rebase moves the feature branch histories to the head of the main branch. It creates new commits Eโ€™, Fโ€™, and Gโ€™ for each commit in the feature branch.

The benefit of rebase is that it has ๐ฅ๐ข๐ง๐ž๐š๐ซ ๐œ๐จ๐ฆ๐ฆ๐ข๐ญ ๐ก๐ข๐ฌ๐ญ๐จ๐ซ๐ฒ.

Rebase can be dangerous if โ€œthe golden rule of git rebaseโ€ is not followed.

๐“๐ก๐ž ๐†๐จ๐ฅ๐๐ž๐ง ๐‘๐ฎ๐ฅ๐ž ๐จ๐Ÿ ๐†๐ข๐ญ ๐‘๐ž๐›๐š๐ฌ๐ž
Never use it on public branches!

Top comments (0)